1 /*设置为简单模式*/
2 USE [master]
3 ALTER DATABASE {0} SET RECOVERY SIMPLE WITH NO_WAIT
4 ALTER DATABASE {0} SET RECOVERY SIMPLE
5
6 /*获取日志文件名称*/
7 USE {0}
8 Declare @logname nvarchar(200)
9 SELECT @logname=name FROM sys.database_files where type=1
10
11 /*收缩日志文件*/
12 DBCC SHRINKFILE (@logname , 0, TRUNCATEONLY)
13
14 /*还原为完全模式*/
15 USE [master]
16 ALTER DATABASE {0} SET RECOVERY FULL WITH NO_WAIT
17 ALTER DATABASE {0} SET RECOVERY FULL