Vrosenberg (8/7/2010)
select distinct 'ALTER TABLE .[dbo].['+rtrim(P.name) +'] CHECK CONSTRAINT all'from [INFORMATION_SCHEMA].[CHECK_CONSTRAINTS] C
join sys.sysobjects O on name=CONSTRAINT_NAME
join sys.sysobjects P on P.id=O.parent_obj
You really should have the WITH CHECK option in that to make sure that the constraints are trusted again, otherwise they aren't as valuable to the optimizer:
SELECT DISTINCT
'ALTER TABLE [dbo].[' + RTRIM(P.name) + '] WITH CHECK CHECK CONSTRAINT all'
FROM [INFORMATION_SCHEMA].[CHECK_CONSTRAINTS] C
JOIN sys.sysobjects O
ON name = CONSTRAINT_NAME
JOIN sys.sysobjects P
ON P.id = O.parent_obj
It would be nice to see these changes integrated into the script, as well as support for multiple schemas, but it is a very good start, thanks!