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


/ Published in: SQL
Save to your folder(s)



Copy this code and paste it in your HTML
  1. -- disable all constraints
  2. EXEC sp_msforeachtable "ALTER TABLE ? NOCHECK CONSTRAINT all"
  3.  
  4. -- enable all constraints
  5. EXEC sp_msforeachtable @command1="print '?'", @command2="ALTER TABLE ? WITH CHECK CHECK CONSTRAINT all"

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.