"IF EXISTS (SELECT 1 FROM sysobjects WHERE type = 'U' AND name = \"table2\")\n"+
"IF EXISTS (SELECT 1 FROM sysobjects WHERE type = 'U' AND name = 'table2')\n"+
    public void testTableConstraints() throws Exception    {        assertEqualsIgnoringWhitespaces(            "SET quoted_identifier on;\n"+            "IF EXISTS (SELECT 1 FROM sysobjects WHERE type = 'RI' AND name = \"testfk\")\n"+            "     ALTER TABLE \"table3\" DROP CONSTRAINT \"testfk\";\n"+            "SET quoted_identifier on;\n"+            "IF EXISTS (SELECT 1 FROM sysobjects WHERE type = 'RI' AND name = \"table2_FK_COL_FK_1_COL_FK_2_table1\")\n"+            "     ALTER TABLE \"table2\" DROP CONSTRAINT \"table2_FK_COL_FK_1_COL_FK_2_table1\";\n"+            "SET quoted_identifier on;\n"+            "SET quoted_identifier on;\n"+            "IF EXISTS (SELECT 1 FROM sysobjects WHERE type = 'U' AND name = \"table3\")\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 = \"table3\"\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 \"table3\"\n"+            "END;\n"+            "SET quoted_identifier on;\n"+            "IF EXISTS (SELECT 1 FROM sysobjects WHERE type = 'U' AND name = \"table2\")\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 = \"table2\"\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 \"table2\"\n"+            "END;\n"+            "SET quoted_identifier on;\n"+            "IF EXISTS (SELECT 1 FROM sysobjects WHERE type = 'U' AND name = \"table1\")\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 = \"table1\"\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 \"table1\"\n"+            "END;\n"+            "SET quoted_identifier on;\n"+            "CREATE TABLE \"table1\"\n"+            "(\n"+            "    \"COL_PK_1\"    VARCHAR(32) NOT NULL,\n"+            "    \"COL_PK_2\"    INT,\n"+            "    \"COL_INDEX_1\" BINARY(100) NOT NULL,\n"+            "    \"COL_INDEX_2\" FLOAT NOT NULL,\n"+            "    \"COL_INDEX_3\" CHAR(4),\n"+            "    PRIMARY KEY (\"COL_PK_1\", \"COL_PK_2\")\n"+            ");\n"+            "CREATE INDEX \"testindex1\" ON \"table1\" (\"COL_INDEX_2\");\n"+            "CREATE UNIQUE INDEX \"testindex2\" ON \"table1\" (\"COL_INDEX_3\", \"COL_INDEX_1\");\n"+            "SET quoted_identifier on;\n"+            "CREATE TABLE \"table2\"\n"+            "(\n"+            "    \"COL_PK\"   INT,\n"+            "    \"COL_FK_1\" INT,\n"+            "    \"COL_FK_2\" VARCHAR(32) NOT NULL,\n"+            "    PRIMARY KEY (\"COL_PK\")\n"+            ");\n"+            "SET quoted_identifier on;\n"+            "CREATE TABLE \"table3\"\n"+            "(\n"+            "    \"COL_PK\" VARCHAR(16),\n"+            "    \"COL_FK\" INT NOT NULL,\n"+            "    PRIMARY KEY (\"COL_PK\")\n"+            ");\n"+            "ALTER TABLE \"table2\" ADD CONSTRAINT \"table2_FK_COL_FK_1_COL_FK_2_table1\" FOREIGN KEY (\"COL_FK_1\", \"COL_FK_2\") REFERENCES \"table1\" (\"COL_PK_2\", \"COL_PK_1\");\n"+            "ALTER TABLE \"table3\" ADD CONSTRAINT \"testfk\" FOREIGN KEY (\"COL_FK\") REFERENCES \"table2\" (\"COL_PK\");\n",            createTestDatabase(TABLE_CONSTRAINT_TEST_SCHEMA));    }