always on 备份清理日志


use [dbname]
declare @bakfile nvarchar(100)--@bakfile备份文件名
set @bakfile='H:\Art_log_bak_'+convert(nvarchar(8),getdate(),112)+'.log'
BACKUP LOG [dbname] TO DISK= @bakfile WITH RETAINDAYS= 1,COMPRESSION --dbName为数据库名

dbcc shrinkfile(logsname,100) --dbName_log为数据库文件逻辑名称,100为希望日志收缩到的MB数
go


Whatever is worth doing is worth doing well.