db-ddlutils-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christoffer Hammarström (JIRA) <j...@apache.org>
Subject [jira] Created: (DDLUTILS-127) MsSqlBuilder does not drop foreign keys to a table before dropping the table.
Date Wed, 30 Aug 2006 12:30:22 GMT
MsSqlBuilder does not drop foreign keys to a table before dropping the table.
-----------------------------------------------------------------------------

                 Key: DDLUTILS-127
                 URL: http://issues.apache.org/jira/browse/DDLUTILS-127
             Project: DdlUtils
          Issue Type: Bug
          Components: Core - SqlServer
            Reporter: Christoffer Hammarström
         Assigned To: Thomas Dudziak


Could not drop object 'Tmp_categories' because it is referenced by a FOREIGN KEY constraint.
Query: IF EXISTS (SELECT 1 FROM sysobjects WHERE type = 'U' AND name = 'Tmp_categories')
BEGIN
  DECLARE @tablename nvarchar(256), @constraintname nvarchar(256)
  DECLARE refcursor CURSOR FOR
  SELECT object_name(objs.parent_obj) tablename, objs.name constraintname
    FROM sysobjects objs JOIN sysconstraints cons ON objs.id = cons.constid
    WHERE objs.xtype != 'PK' AND object_name(objs.parent_obj) = 'Tmp_categories'  OPEN refcursor
  FETCH NEXT FROM refcursor INTO @tablename, @constraintname
  WHILE @@FETCH_STATUS = 0
    BEGIN
      EXEC ('ALTER TABLE '+@tablename+' DROP CONSTRAINT '+@constraintname)
      FETCH NEXT FROM refcursor INTO @tablename, @constraintname
    END
  CLOSE refcursor
  DEALLOCATE refcursor
  DROP TABLE Tmp_categories
END;

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

Mime
View raw message