2 edited body; edited tags; edited title
source | link

To drop an MS SQLa table, do I have to drop all Foreign Key Constraintsforeign key constraints or can iI just NOCHECK them?

I know you cannot drop a table that has active foreign key constraints.

So I was wondering is it safe to:

ALTER TABLE myTable NOCHECK CONSTRAINT all
DROP TABLE myTable

Rather than Droppingdropping the constraints first, table dropping:

ALTER TABLE myTable DROP Constraint FK_MyTable_AnotherTable
ALTER TABLE myTable DROP Constraint FK_MyTable_YetAnotherTable
DROP TABLE myTable 

To drop an MS SQL table, do I have to drop all Foreign Key Constraints or can i just NOCHECK them?

I know you cannot drop a table that has active foreign key constraints.

So I was wondering is it safe to:

ALTER TABLE myTable NOCHECK CONSTRAINT all
DROP TABLE myTable

Rather than Dropping the constraints first, table dropping:

ALTER TABLE myTable DROP Constraint FK_MyTable_AnotherTable
ALTER TABLE myTable DROP Constraint FK_MyTable_YetAnotherTable
DROP TABLE myTable 

To drop a table, do I have to drop all foreign key constraints or can I just NOCHECK them?

I know you cannot drop a table that has active foreign key constraints.

So I was wondering is it safe to:

ALTER TABLE myTable NOCHECK CONSTRAINT all
DROP TABLE myTable

Rather than dropping the constraints first, table dropping:

ALTER TABLE myTable DROP Constraint FK_MyTable_AnotherTable
ALTER TABLE myTable DROP Constraint FK_MyTable_YetAnotherTable
DROP TABLE myTable 
    Post Migrated Here from stackoverflow.com
1
source | link

To drop an MS SQL table, do I have to drop all Foreign Key Constraints or can i just NOCHECK them?

I know you cannot drop a table that has active foreign key constraints.

So I was wondering is it safe to:

ALTER TABLE myTable NOCHECK CONSTRAINT all
DROP TABLE myTable

Rather than Dropping the constraints first, table dropping:

ALTER TABLE myTable DROP Constraint FK_MyTable_AnotherTable
ALTER TABLE myTable DROP Constraint FK_MyTable_YetAnotherTable
DROP TABLE myTable