Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Script to remove and add FK constraints in a datab

Author  Topic 

mavericky
Posting Yak Master

117 Posts

Posted - 2012-02-16 : 13:34:20
Hi,
Can anyone tell me if there is any way to :
1.> create a script to drop all the Foreign Key constraints from a database
2.> create a script to create all the Foreign Key constraints on a database

Thanks in anticipation,
Mavericky

X002548
Not Just a Number

15586 Posts

Posted - 2012-02-16 : 13:43:43
http://weblogs.sqlteam.com/brettk/archive/2007/02/22/60118.aspx

http://weblogs.sqlteam.com/brettk/archive/2007/03/01/60124.aspx

Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-02-16 : 15:39:34
quote:
Originally posted by mavericky

Hi,
Can anyone tell me if there is any way to :
1.> create a script to drop all the Foreign Key constraints from a database
2.> create a script to create all the Foreign Key constraints on a database

Thanks in anticipation,
Mavericky


you can make use of INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS or sys.foreign_keys and sys.foreign_key_columns for that

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -