SQL Server清空数据库中ldf日志文件

时间:2021-12-14 13:51:59

USE [master]
ALTER DATABASE [Whir_InternalSystem]
SET RECOVERY SIMPLE WITH NO_WAIT
ALTER DATABASE [Whir_InternalSystem]
SET RECOVERY SIMPLE
GO
USE [Whir_InternalSystem]
DECLARE @logname VARCHAR(150)
SELECT @logname = NAME
FROM sys.database_files
WHERE NAME LIKE'%log'
DBCC SHRINKFILE(@logname, 11, TRUNCATEONLY)
GO
USE [master]
ALTER DATABASE [Whir_InternalSystem]
SET RECOVERY FULL WITH NO_WAIT
ALTER DATABASE [Whir_InternalSystem]
SET RECOVERY FULL
GO

使用时将[Whir_InternalSystem] 替换成你的数据库名称即可!

关注公众号githubcn,免费获取更多学习视频教程

SQL Server清空数据库中ldf日志文件