标签:
if exists (select * from sysobjects where type=‘P‘ and name=N‘P_DeleteAllData‘ )
drop procedure P_DeleteAllData
go
CREATE PROCEDURE P_DeleteAllData
as
EXEC sp_MSforeachtable ‘ALTER TABLE ? NOCHECK CONSTRAINT ALL‘ --禁用约束
EXEC sp_MSforeachtable ‘ALTER TABLE ? DISABLE TRIGGER ALL‘ --禁用触发器
EXEC sp_MSforeachtable ‘DELETE FROM ?‘ --删除所有表中的数据
EXEC sp_MSforeachtable ‘ALTER TABLE ? CHECK CONSTRAINT ALL‘ --启用约束
EXEC sp_MSforeachtable ‘ALTER TABLE ? ENABLE TRIGGER ALL‘ --启用触发器
go
标签:
原文地址:http://www.cnblogs.com/wxy520/p/5333305.html