--删除所有表数据
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'
EXEC sp_MSFOREACHTABLE 'SELECT * FROM ?'
--缩小日志
ALTER DATABASE template SET RECOVERY SIMPLE
DBCC SHRINKDATABASE(template, 0)
ALTER DATABASE template SET RECOVERY FULL
--选择数据库右键,分别选择收缩文件和数据