October 7, 2013 at 3:55 pm
I am missing something here. I need to create a script to do this.
To disable I do the following command
EXECUTE sp_msforeachtable @command1="Print 'Test'", @Command2 ="ALTER TABLE Foo.tblFoo NOCHECK CONSTRAINT all"
To enable the FK I do this
EXECUTE sp_msforeachtable @command1="Print 'Test'", @Command2 ="ALTER TABLE Foo.tblFoo CHECK CONSTRAINT all"
The check existing data on creation in the table is still set to "No". I can't seem to google a solution. Any of you potentially know if this can be done without using the ui?
October 8, 2013 at 4:24 am
EXECUTE sp_msforeachtable @command1="Print 'Test'", @Command2 ="ALTER TABLE Foo.tblFoo CHECK CHECK CONSTRAINT all"
_______________________________________________________________
To get quick answer follow this link:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
October 8, 2013 at 7:16 am
I did find that one in searching
EXECUTE sp_msforeachtable @command1="Print 'Test'", @Command2 ="ALTER TABLE Foo.tblFoo WITH CHECK CHECK CONSTRAINT all"
Am I doing something incorrectly because it seems to have no effect on the FK
October 10, 2013 at 1:44 pm
Hey sorry about the confusion. I must have been doing something differently that was not working. I tried this again today and it worked. Thanks
Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy