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