SQL Server 清除数据库日志脚本(转)

Use master
go

declare @dbname varchar(50)
declare temp_cur cursor scroll for select name from sysdatabases
open temp_cur
fetch first from temp_cur into @dbname
while @@fetch_status =0 
begin
  
exec ('backup log ['+@dbname+'] with no_log')
  
exec ('dbcc shrinkdatabase(['+@dbname+'])')
  
exec ('dbcc checkcatalog (['+@dbname+'])')
  
exec ('dump transaction ['+@dbname+'] with no_log')
  
fetch next from temp_cur into @dbname
end
close temp_cur
deallocate temp_cur

相关文章:

  • 2021-11-07
  • 2021-11-27
  • 2021-10-01
  • 2022-01-15
  • 2021-12-21
  • 2021-12-21
  • 2021-12-21
猜你喜欢
  • 2021-11-01
  • 2022-12-23
  • 2022-01-19
  • 2022-12-23
  • 2021-08-28
  • 2022-01-21
  • 2021-12-21
相关资源
相似解决方案