数据库
首页 > 数据库> > SQL Server 数据库清空ldf日志文件

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

作者:互联网

USE [master]
ALTER DATABASE [DB_Develop]
SET RECOVERY SIMPLE WITH NO_WAIT
ALTER DATABASE [DB_Develop] 
SET RECOVERY SIMPLE
GO
USE [DB_Develop]
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 [DB_Develop]
SET RECOVERY FULL WITH NO_WAIT
ALTER DATABASE [DB_Develop] 
SET RECOVERY FULL
GO

  使用时将DB_Develop更换为你需要操作的数据库名即可。

标签:SET,Develop,ldf,DATABASE,DB,Server,SQL,ALTER,RECOVERY
来源: https://www.cnblogs.com/88223100/p/How_to_clearn_sql_server-ldf_file.html