用脚本缩小日志

来源:互联网 发布:php处理ajax跨域 编辑:程序博客网 时间:2024/05/01 11:13
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>

因为客户使用的数据库时常因为日志过大而导致硬盘空间不够,或者备份出来的文件太大无法通过邮件传送。 
 闲下有余,参考SQLSERVER的帮助文件,写了如下脚本,可以截断日志,以达到缩小文件的目的。有空大家可以在自己的SQLSERVER上测试下效果哦。。。:)也许对有些情况导致的日志过大没有作用,这点可以同各位同仁互相交流下。

--在MASTER数据库中执行以下脚本(使用查询分析器)
declare@dbnamevarchar(50)
declaretemp_curcursorscrollforselectnamefromsysdatabases
opentemp_cur
fetchfirstfromtemp_curinto@dbname
while@@fetch_status=0
begin
 exec('backuplog'+@dbname+'withno_log')
 exec('dbccshrinkdatabase('+@dbname+')')
 exec('dbcccheckcatalog('+@dbname+')')
 exec('dumptransaction'+@dbname+'withno_log')
 fetchnextfromtemp_curinto@dbname
end
closetemp_cur
deallocatetemp_cur


<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
原创粉丝点击