内容显示页
 
类别:数据库+SQL | 浏览(757) | 2008-7-7 13:49:49

有些数据库的日志增加很快,有些服务器的数据库很多,有几十个,如果一个一个的收缩数据库,很慢,很累,很无聊。

declare cur cursor for select name from Master..SysDatabases where name<>'master' and name<>'model' and name<>'msdb' and name<>'Northwind' and name<>'pubs'
declare @tb sysname 

open cur 
fetch next from cur into @tb 
while @@fetch_status=0 
begin 
  exec ('dump transaction ['+@tb+'] with no_log') 
  exec ('backup log ['+@tb+'] with no_log') 
  exec ('dbcc shrinkdatabase(['+@tb+'])') 
  fetch next from cur into @tb 
end 
close cur 
deallocate cur

 


引用:
MSSQL收缩所有数据库,让*.ldf日志文件都变成1M
http://www.yongfa365.com/item/MSSQL-Shrink-All-Database-yongfa365.html
 
 
相关链接
 
网友评论:
姓名: 记住我
网址:
邮箱:
内容:
验证码:  验证码图片 看不清? 换张图试试
 
     
 
 
文章分类
 
 
.Net + C#(74)
 
 
ASP+VBS(161)
 
 
 
Linux(10)
 
 
 
web 2.0(26)
 
 
 
 
 
心程(68)
 
生活(97)
 
 
     

Power by :柳永法(yongfa365)'Blog  | 京ICP备07011491号  QQ:64049027  E-mail:64049027@qq.com Weibo

申请友情链接 要求:跟本站主题相类似正规网站,双方交换为首页位置

转载请注明来源,以便后人及时得到最新、修正、加强版!!!