Sunday, February 19, 2012

How to cleanup all database?

hello,if I want to cleanup all the data that in a database,how to do?
thanks!run this query and execute the result.it will clean ur DB.
Note:It does not deal with foreign constraints but when using brute force, running it a few times should deal.

select 'truncate table ['+o.name+']'
from sysobjects o
where o.xtype='U'
and o.name <>'dtproperties'|||sp_MSforeachtable 'delete from ?'
This is simpler|||I prefer "drop database ..." It cleans up all those pesky files that SQL Server never really needed anyway.|||sp_MSforeachtable 'delete from ?'
This is simpler
it means I have to run this query many times!
I want to cleanup my database in one times|||You could generate scripts for dropping and re-creating all table objects (+concerned indexes, keys, constraints etc)

No comments:

Post a Comment