Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Re-Trust Untrusted Foreign Keys and Constraints Expand / Collapse
Author
Message
Posted Friday, May 31, 2013 10:39 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Monday, July 28, 2014 1:11 PM
Points: 1,328, Visits: 730
Comments posted to this topic are about the item Re-Trust Untrusted Foreign Keys and Constraints
Post #1458793
Posted Monday, June 17, 2013 8:14 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Monday, July 28, 2014 11:16 AM
Points: 27, Visits: 77
Thanks for the nice script. I needed to change collation on a database which involved ripping out every schema bound object and this came in quite handy with retrusting everything. Thankfully I was able to retrust foreign keys and check constraints with 0 errors. My only suggestion I can think of is to make an easier toggle between fk or ck. It could be as simple as changing your select line to include a commented out line like this:

SELECT '[' + s.name + '].' + '[' + o.name + ']' AS TableName
,i.name AS FKName
FROM sys.foreign_keys i
-- FROM sys.check_constraints i

You could go fancier such as setting a flag that allows either option or both but simply having a commented out line for future reference is nice.
Post #1464165
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse