在sqlserver2008中收缩日志文件

时间:2022-01-04 07:13:41

—先备份数据库(含日志文件)
use myhis
go
backup database myhis to disk=’d:\myhis_rzbak’
go
—设为简单恢复模式
use [master]
go
alter database myhis set recovery simple with no_wait
go
alter database myhis set recovery simple
go
—收缩数据库日志文件为8M
use myhis
go
dbcc shrinkfile(myhis_log,8)
go
—重新设为完整恢复模式
use master
go
alter database myhis set recovery full with no_wait
go
alter database myhis set recovery full go