I've got this script
TRUNCATE TABLE [dbo].[TableOne]
TRUNCATE TABLE [dbo].[TableTwo]
SET IDENTITY_INSERT [dbo].[TableOne] ON
...Insert stuff....
SET IDENTITY_INSERT [dbo].[TableOne] OFF
SET IDENTITY_INSERT [dbo].[TableTwo] ON
...Insert other stuff....
SET IDENTITY_INSERT [dbo].[TableTwo] OFF
But I can't truncate TableTwo
because of a foreign key constraint. But that's okay, because I am truncating both the relevant tables and inserting fresh data.
So is it possible to just temporarily disable the foreign key or something along those lines, and then reactivate it at the end of the script?
disable FK
[the script]
enable FK