----修改数据库日志模式为简单
DECLARE @strSQL VARCHAR(4000),
@strDataBaseName VARCHAR(100)
SET @strDataBaseName = DB_NAME();
SET @strSQL = 'alter database [' + @strDataBaseName + '] set recovery simple with no_wait;';
EXEC(@strSQL);
SET @strSQL = 'alter database [' + @strDataBaseName + '] set recovery simple ;';
EXEC(@strSQL);
-----收缩文件
SELECT @strSQL='DBCC SHRINKDATABASE(N''' + @strDataBaseName + ''', TRUNCATEONLY );'
EXEC(@strSQL);
----修改数据库日志模式为完整
SET @strSQL = 'alter database [' + @strDataBaseName + '] set recovery full with no_wait;';
EXEC(@strSQL);
SET @strSQL = 'alter database [' + @strDataBaseName + '] set recovery full ;';
EXEC(@strSQL);