MS SQL Delete all the data from the tables.
by brian on Nov.21, 2008, under coding, mmsql, sql
Here’s a helpful, and perhaps dangerous, little tidbit of code for SQL Server 2005. It deletes all of the data from all of the tables. To be completely effective, the command may need to be run more than once because of foreign keys. Basically run it until there aren’t any errors. Then the db is clean and empty of all data.
exec sp_MSForeachTable "delete from ?"
the sp_MSForeachTable is a very useful system stored procedure.
