Usefull T-SQL Constraint and other commands

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

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.


Filed under: SQL
Written on: 28 Jun 2006 ·

kick it on DotNetKicks.com

Leave a Reply