Usefull T-SQL Constraint and other commands
I’ve bean using these for quite some time, and have used them again today so it came cross my mind to mention them on my blog.
Here goes nothing…
– Disable all constraints for a given table
ALTER TABLE [Some_Table] NOCHECK CONSTRAINT ALL
– Enable all constraints for a given table
ALTER TABLE [Some_Table] CHECK CONSTRAINT ALL
– Reseed the identity of a table back to zero (next record will have auto ident set to 1)
DBCC CHECKIDENT ([Some_Table], RESEED, 0)
– “Run” table constraints on a table to verify that everything is ok
DBCC CHECKCONSTRAINTS (’[Some_Table]‘)
hope this helps someone, it sure did me over the past years.
