Return to Snippet

Revision: 29399
at July 28, 2010 19:05 by keanu


Initial Code
-- disable all constraints
EXEC sp_msforeachtable "ALTER TABLE ? NOCHECK CONSTRAINT all"

-- enable all constraints
exec sp_msforeachtable @command1="print '?'", @command2="ALTER TABLE ? WITH CHECK CHECK CONSTRAINT all"

Initial URL
http://stackoverflow.com/questions/159038/can-foreign-key-constraints-be-temporarily-disabled-using-tsql

Initial Description

                                

Initial Title
暫時性關閉/開啟 SQL Server 的 FK Constraints

Initial Tags

                                

Initial Language
SQL