数据库
首页 > 数据库> > Sql Server 2008 R2 清空数据库中ldf日志文件

Sql Server 2008 R2 清空数据库中ldf日志文件

作者:互联网

/************************************************************
* Sql Server 2008 R2 清空数据库中ldf日志文件
* 将[SciProject]e替换为您要操作的数据库即可
************************************************************/
USE [master]
ALTER DATABASE [SciProject]
SET RECOVERY SIMPLE WITH NO_WAIT
ALTER DATABASE [SciProject]
SET RECOVERY SIMPLE
GO
USE [SciProject]
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 [SciProject]
SET RECOVERY FULL WITH NO_WAIT
ALTER DATABASE [SciProject]
SET RECOVERY FULL
GO

标签:SciProject,SET,RECOVERY,R2,DATABASE,数据库,logname,Sql,ldf
来源: https://www.cnblogs.com/huweijian/p/14004868.html