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

  微软不公开的存储过程 ,代码如下:
-- 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

你可能感兴趣的:(数据库)