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
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/16436858/viewspace-609342/
,如需转载,请注明出处,否则将追究法律责任。