把这个存储过程添加到master数据库里,需要截断数据日志的时候执行一下就OK了。
CREATE Procedure sp_mrx_truncatelog
AS
declare db cursor LOCAL for SELECT NAME FROM sysdatabases
declare @dbname varchar(200),@sql varchar(2000)
OPEN db
FETCH NEXT FROM db into @dbname
while(@@FETCH_STATUS<>-1)
BEGIN
if(@@FETCH_STATUS<>-2)
BEGIN
set @sql = 'BACKUP LOG '+@dbname+' WITH TRUNCATE_ONLY'
print @sql
exec(@sql)
END
FETCH NEXT FROM db into @dbname
END
CLOSE db
DEALLOCATE db
--print '------------'
--print @totalcount
GO
AS
declare db cursor LOCAL for SELECT NAME FROM sysdatabases
declare @dbname varchar(200),@sql varchar(2000)
OPEN db
FETCH NEXT FROM db into @dbname
while(@@FETCH_STATUS<>-1)
BEGIN
if(@@FETCH_STATUS<>-2)
BEGIN
set @sql = 'BACKUP LOG '+@dbname+' WITH TRUNCATE_ONLY'
print @sql
exec(@sql)
END
FETCH NEXT FROM db into @dbname
END
CLOSE db
DEALLOCATE db
--print '------------'
--print @totalcount
GO