"     DECLARE @reftable nvarchar(60), @constraintname nvarchar(60)\n"+ "     DECLARE refcursor CURSOR FOR\n"+ "     select reftables.name tablename, cons.name constraintname\n"+ "      from sysobjects tables,\n"+ "           sysobjects reftables,\n"+ "           sysobjects cons,\n"+ "           sysreferences ref\n"+ "       where tables.id = ref.rkeyid\n"+ "         and cons.id = ref.constid\n"+ "         and reftables.id = ref.fkeyid\n"+ "         and tables.name = 'constraints'\n"+ "     OPEN refcursor\n"+ "     FETCH NEXT from refcursor into @reftable, @constraintname\n"+ "     while @@FETCH_STATUS = 0\n"+ "     BEGIN\n"+ "       exec ('alter table '+@reftable+' drop constraint '+@constraintname)\n"+ "       FETCH NEXT from refcursor into @reftable, @constraintname\n"+ "     END\n"+ "     CLOSE refcursor\n"+ "     DEALLOCATE refcursor\n"+ "     DROP TABLE \"constraints\"\n"+
"  DECLARE @tablename nvarchar(60), @constraintname nvarchar(60)\n"+ "  DECLARE refcursor CURSOR FOR\n"+ "  SELECT object_name(objs.parent_obj) tablename, objs.name constraintname\n"+ "    FROM sysobjects objs JOIN sysconstraints cons ON objs.id = cons.constid\n"+ "    WHERE objs.xtype != 'PK' AND object_name(objs.parent_obj) = 'constraints'  OPEN refcursor\n"+ "  FETCH NEXT FROM refcursor INTO @tablename, @constraintname\n"+ "  WHILE @@FETCH_STATUS = 0\n"+ "    BEGIN\n"+ "      EXEC ('ALTER TABLE '+@tablename+' DROP CONSTRAINT '+@constraintname)\n"+ "      FETCH NEXT FROM refcursor INTO @tablename, @constraintname\n"+ "    END\n"+ "  CLOSE refcursor\n"+ "  DEALLOCATE refcursor\n"+ "  DROP TABLE \"constraints\"\n"+
    public void testColumnConstraints() throws Exception    {        // this is not valid sql as a table can have only one identity column at most         assertEqualsIgnoringWhitespaces(            "SET quoted_identifier on;\n"+            "SET quoted_identifier on;\n"+            "IF EXISTS (SELECT 1 FROM sysobjects WHERE type = 'U' AND name = 'constraints')\n"+            "BEGIN\n"+            "     DECLARE @reftable nvarchar(60), @constraintname nvarchar(60)\n"+            "     DECLARE refcursor CURSOR FOR\n"+            "     select reftables.name tablename, cons.name constraintname\n"+            "      from sysobjects tables,\n"+            "           sysobjects reftables,\n"+            "           sysobjects cons,\n"+            "           sysreferences ref\n"+            "       where tables.id = ref.rkeyid\n"+            "         and cons.id = ref.constid\n"+            "         and reftables.id = ref.fkeyid\n"+            "         and tables.name = 'constraints'\n"+            "     OPEN refcursor\n"+            "     FETCH NEXT from refcursor into @reftable, @constraintname\n"+            "     while @@FETCH_STATUS = 0\n"+            "     BEGIN\n"+            "       exec ('alter table '+@reftable+' drop constraint '+@constraintname)\n"+            "       FETCH NEXT from refcursor into @reftable, @constraintname\n"+            "     END\n"+            "     CLOSE refcursor\n"+            "     DEALLOCATE refcursor\n"+            "     DROP TABLE \"constraints\"\n"+            "END;\n"+            "SET quoted_identifier on;\n"+            "CREATE TABLE \"constraints\"\n"+            "(\n"+            "    \"COL_PK\"               VARCHAR(32),\n"+            "    \"COL_PK_AUTO_INCR\"     INT IDENTITY(1,1),\n"+            "    \"COL_NOT_NULL\"         BINARY(100) NOT NULL,\n"+            "    \"COL_NOT_NULL_DEFAULT\" FLOAT DEFAULT -2.0 NOT NULL,\n"+            "    \"COL_DEFAULT\"          CHAR(4) DEFAULT 'test',\n"+            "    \"COL_AUTO_INCR\"        DECIMAL(19,0) IDENTITY(1,1),\n"+            "    PRIMARY KEY (\"COL_PK\", \"COL_PK_AUTO_INCR\")\n"+            ");\n",            createTestDatabase(COLUMN_CONSTRAINT_TEST_SCHEMA));    }