日志收缩

DECLARE @dbname VARCHAR(60)

SELECT @dbname = CONVERT(VARCHAR(60), DB_NAME())

EXEC('DUMP TRANSACTION ['+@dbname+'] WITH  NO_LOG') 

DECLARE @logname VARCHAR(60) 

SELECT  @logname = name

    FROM sys.sysfiles

    WHERE name LIKE '%log' 

EXEC('BACKUP LOG ['+@dbname+'] WITH NO_LOG')

EXEC ('DBCC SHRINKFILE(['+@logname+'],1)')
posted @ 2011-06-15 21:56  qanholas  阅读(209)  评论(0编辑  收藏  举报