在SQL SERVER 2000/2005中,收缩数据库日志文件的sql语句如下:
DUMP TRAN DBName WITH NO_LOG
BACKUP LOG DBName WITH NO_LOG
DBCC SHRINKFILE(DBName_Log)
然而在SQL 2008中已经弃用了此功能,在网上找了一翻之后可通过以下语句来收缩日志:
USE [master]
GO
ALTER DATABASE DBName SET RECOVERY SIMPLE WITH NO_WAIT
GO
ALTER DATABASE DBName SET RECOVERY SIMPLE
GO
USE DBName
GO
DBCC SHRINKFILE (N'LogFileName' , 0,TRUNCATEONLY)
GO
USE [master]
GO
ALTER DATABASE DBName SET RECOVERY FULL WITH NO_WAIT
GO
ALTER DATABASE DBName SET RECOVERY FULL
GO