I gave below one to re enable constrain SqlCommand md=new SqlCommand("exec sp_MSforeachtable @command1 = 'print' '?', @command2 = 'ALTER TABLE ? WITH CHECK CHECK CONSTRAINT all'",con); md.ExecuteNonQuery(); But It Gave "incorrect syntax near '?'.
-- Disable Constraints at DB level EXEC sp_MSForEachTable 'ALTER TABLE ? NOCHECK CONSTRAINT ALL' -- Enable Constraints at DB level EXEC sp_MSForEachTable 'ALTER TABLE ? CHECK CONSTRAINT ALL'
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)