Is it possible to defer referential integrity checks until the end of a transaction in SQL Server?

末鹿安然 提交于 2019-11-30 21:40:09

Looks like sql server doesn't allow this, but you aren't the only one who wants it. It's part of the SQL 92 standard, so they've had 17 years now to figure it out. Then again, MySQL doesn't support it either (although Oracle does).

Reordering the statements is probably your best option.

You would be better off determining the correct order so that the transaction can fail at the appropriate time. This should be a one-time determination.

SQL Server does not have this feature.

May I humbly suggest that if it's tricky to determine the correct insertion order (or there is not one), that your database design may need to be refactored or at least examined very carefully.

If you are on SQL Server 2008, you can use MERGE to combine insert/delete into a single RI-safe transaction...

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!