Reputation: 81
I am using
SET FOREIGN_KEY_CHECKS=0;
for My sql but i need the same query in Sql Server, I tried this
ALTER TABLE MyTable NOCHECK CONSTRAINT ALL;
but its not working for me somehow. Can anybody tell me how to write
SET FOREIGN_KEY_CHECKS=1;
same query in sql server?
Upvotes: 0
Views: 6478
Reputation: 402
Simply:
ALTER TABLE MyTable
NOCHECK CONSTRAINT ALL;
GO
INSERT INTO MyTable
...
ALTER TABLE MyTable
CHECK CONSTRAINT ALL;
GO
You can check then if any keys violate the constraints...
DBCC CHECKCONSTRAINTS('MyTable')
GO
Upvotes: 6