2006-09-18

Delete All Rows

Many a time i have wanted to delete all the rows from all the tables in the database. It usually involves a script getting all the names of the tables and deleting one at a time. This script is awesome where you can do it in one line:

EXEC sp_MSforeachtable @command1 = "TRUNCATE TABLE ?"

How many other things will this make easier.

No comments: