清空一个数据库中所有数据

  微软不公开的存储过程 ,代码如下:
--Removed CHECK Constraint-------------------------
EXEC sp_MSForEachTable 'ALTER TABLE ? NOCHECK CONSTRAINT ALL' --NOCHECK Constraints
print 'All Constraints Disable'
go

--truncate All tables  if trying to empty the database 
 --- Ensure the T_X_ref database is located on a different database

-------------  Truncate All Tables from Model ----------------
--
---To limit tables a table with sub model tables must be created  and used joins-----
EXEC sp_MSForEachTable 'truncate TABLE ? '
print 'All tables truncated'
go
posted @ 2009-08-17 11:22  小师傅  阅读(340)  评论(0编辑  收藏  举报