Created
April 29, 2014 06:27
-
-
Save sankars/11392071 to your computer and use it in GitHub Desktop.
Sql server DDL commands
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- From http://stackoverflow.com/questions/155246/how-do-you-truncate-all-tables-in-a-database-using-tsql | |
| -- disable all constraints | |
| EXEC sp_msforeachtable "ALTER TABLE ? NOCHECK CONSTRAINT all" | |
| -- delete data in all tables | |
| EXEC sp_MSForEachTable "DELETE FROM ?" | |
| -- enable all constraints | |
| exec sp_msforeachtable "ALTER TABLE ? WITH CHECK CHECK CONSTRAINT all" | |
| -- to reseed tables | |
| EXEC sp_MSforeachtable "DBCC CHECKIDENT ( '?', RESEED, 0)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment