Created
September 30, 2016 23:51
-
-
Save digioz/c932597df40f07891083eed537db93c6 to your computer and use it in GitHub Desktop.
Delete all rows in all tables in Microsoft SQL Server
This file contains 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
EXEC sp_MSForEachTable 'DISABLE TRIGGER ALL ON ?' | |
GO | |
EXEC sp_MSForEachTable 'ALTER TABLE ? NOCHECK CONSTRAINT ALL' | |
GO | |
EXEC sp_MSForEachTable 'DELETE FROM ?' | |
GO | |
EXEC sp_MSForEachTable 'ALTER TABLE ? CHECK CONSTRAINT ALL' | |
GO | |
EXEC sp_MSForEachTable 'ENABLE TRIGGER ALL ON ?' | |
GO |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment