USE [master] GO ALTER DATABASE [DATABASE] SET RECOVERY SIMPLE WITH NO_WAIT GO ALTER DATABASE [DATABASE] SET RECOVERY SIMPLE --简单模式 GO USE [DATABASE] GO DBCC SHRINKFILE (N'DATABASE_Log' , 11, TRUNCATEONLY) GO USE [master] GO ALTER DATABASE [DATABASE] SET RECOVERY FULL WITH NO_WAIT GO ALTER DATABASE [DATABASE] SET RECOVERY FULL --还原为完全模式 GO
DECLARE @TABLE NVARCHAR(4000) DECLARE @LOG NVARCHAR(4000) SET @TABLE='ML_RuiPu_Mes_V2' SET @LOG='RPMES_log' DECLARE @TSQL NVARCHAR(4000) SET @TSQL=N' USE [master] ALTER DATABASE '+@TABLE+' SET RECOVERY SIMPLE WITH NO_WAIT ALTER DATABASE '+@TABLE+' SET RECOVERY SIMPLE USE '+@TABLE+' DBCC SHRINKFILE (N'''+@LOG+''' , 11, TRUNCATEONLY) USE [master] ALTER DATABASE '+@TABLE+' SET RECOVERY FULL WITH NO_WAIT ALTER DATABASE '+@TABLE+' SET RECOVERY FULL ' EXEC sp_executesql @TSQL