/*设置为简单模式*/
USE [master]
ALTER DATABASE {0} SET RECOVERY SIMPLE WITH NO_WAIT
ALTER DATABASE {0} SET RECOVERY SIMPLE /*获取日志文件名称*/
USE {0}
Declare @logname nvarchar(200)
SELECT @logname=name FROM sys.database_files where type=1 /*收缩日志文件*/
DBCC SHRINKFILE (@logname , 0, TRUNCATEONLY) /*还原为完全模式*/
USE [master]
ALTER DATABASE {0} SET RECOVERY FULL WITH NO_WAIT
ALTER DATABASE {0} SET RECOVERY FULL
{0}替换成数据库名称即可。