伯乐共勉

讨论。NET专区
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

sql server日志损坏的常见处理办法

Posted on 2006-01-02 00:31  伯乐共勉  阅读(339)  评论(1编辑  收藏  举报

可以进行如下举例。
我们在计算机上新建一个 hello数据库,文件存放在c:\下。
然后新建一个表。接着将SQL SERVER停止。用随便一个文件更名为
hello_log.ldf来覆盖c:\下的同名的文件
再启动sql server,是不是发现这个数据库置疑了。
一般用分离后再附加单个文件或用sp_attach_single_file也搞不定。我们可以尝试用以下办法。

exec sp_configure 'allow update',1 reconfigure with override


update sysdatabases set status=32768 where name='hello'


dbcc rebuild_log ('hello','c:\hello_log1.ldf')


update sysdatabases set status=0 where name='hello'


restore database hello with recovery


exec sp_configure 'allow update',0 reconfigure with override