create PROCEDURE [dbo].[Utils_DBShrink]
@DBName nvarchar(50)
AS
BEGIN
declare @sql nvarchar(max) =
--将“恢复模式”设置为“简单”
'ALTER DATABASE ' + @DBName + ' SET RECOVERY SIMPLE' + CHAR(13) + CHAR(10) +
--收缩数据文件
'DBCC SHRINKDATABASE(' + @DBName + ')' + CHAR(13) + CHAR(10) +
--将“恢复模式”设置为“完整”
'ALTER DATABASE ' + @DBName + ' SET RECOVERY FULL WITH NO_WAIT' + CHAR(13) + CHAR(10) +
'ALTER DATABASE ' + @DBName + ' SET RECOVERY FULL'
--print @sql
exec (@sql)
return @@ERROR
END
05-30
202
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)