步骤:
1、命令:Backup LOG [数据库名] to disk =’nul’
2、执行(上方叹号执行)
3、输入第二条命令 dbcc shrinkfile (‘数据库日志名称’,100)
4、再次执行即可
以下是Always on 数据库截断
在 d 盘下创建 Tools\bat_tools 文件夹
1. 创建 backup_log.sql 文件, 脚本如下:
use [dbName]
declare @bakfile nvarchar(100)–@bakfile备份文件名
set @bakfile=’d:\database_bak\log_bak_’+convert(nvarchar(8),getdate(),112)+’.log’
BACKUP LOG [dbName] TO DISK= @bakfile WITH RETAINDAYS= 1,COMPRESSION –dbName为数据库名
dbcc shrinkfile(dbName_log,100) –dbName_log为数据库文件逻辑名称,100为希望日志收缩到的MB数
go
2. 创建 del_log.bat 文件, 内容如下:
sqlcmd -S localhost -U loginName -P password -i d:\tools\bat_tools\backup_log.sql
@echo off
forfiles /P D:\database_bak /s /m *.log /d -7 /c “cmd /c del /q @path ”
执行备份操作, 完成之后删除备份文件夹下所有 .log 结尾的超过7天的文件。
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。
评论(5)
I’m amazed by your skill to make even the most routine subjects intriguing. Well done to you!
I can tell the author has put in a lot of thought and effort, it shows.
I don’t even know how I stopped up here, but I believed this
submit used to be great. I don’t realize who you are however definitely you’re going
to a well-known blogger should you are not already. Cheers!
Your writing always leaves me hooked right until the end; I’m never disappointed.
The way you write is engaging; I couldn’t pause going through once I started.