Backup log [dbxxx] with truncate_only
sql server 2008之后不支持此操作,需要改为:
BACKUP LOG dbxxx TO DISK='NUL:'
如果提示数据库没有备份,则可以先做一个差异化备份。
再执行上面的语句,又提示: The log was not truncated because records at the beginning of the log are pending replication or Change Data Capture. Ensure the Log Reader Agent or capture job is running or use sp_repldone to mark transactions as distributed or captured
或:
因为其开始处的记录是挂起的复制操作或变更数据捕获。请确保日志读取器代理或捕获作业正在运行,
此时,需要告诉DB此日志可以截断:
EXEC sp_repldone @xactid = NULL, @xact_segno = NULL, @numtrans = 0, @time = 0, @reset = 1
然后再执行: BACKUP LOG dbxxx TO DISK='NUL:'
,告诉DB日志已经备份,可以shink,最后:
DBCC SHRINKFILE (dbxxxx_Log, 1);