问题
Possible Duplicate:
How to delete all rows from all tables in a SQL Server database?
I want to delete all rows from a SQL Server 2005 database.
Can anyone to define a procedure to delete all rows from database by using single query?
回答1:
In that case, this will work:
EXEC sp_MSForEachTable 'ALTER TABLE ? NOCHECK CONSTRAINT ALL'
GO
EXEC sp_MSForEachTable 'DELETE FROM ?'
GO
EXEC sp_MSForEachTable 'ALTER TABLE ? CHECK CONSTRAINT ALL'
GO
thanks @MAT
回答2:
Have you tried : delete * FROM database.* ?
来源:https://stackoverflow.com/questions/10831753/delete-all-rows-from-database-by-using-single-query