Clear all data from SQL Server database

Easy as:

sp_msforeachtable 'ALTER TABLE ? NOCHECK CONSTRAINT all'
GO

sp_msforeachtable 'DELETE ?'
GO

sp_msforeachtable 'ALTER TABLE ? CHECK CONSTRAINT all'
GO

Something to add?

This site uses Akismet to reduce spam. Learn how your comment data is processed.