SQL 2005/2008质疑修复
生活随笔
收集整理的這篇文章主要介紹了
SQL 2005/2008质疑修复
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
SQL 2005/2008質(zhì)疑修復(fù)
SQL 2005 質(zhì)疑修復(fù)
alter database 置疑數(shù)據(jù)庫 set emergency go alter database 置疑數(shù)據(jù)庫 set single_user with rollback immediate go use master go alter database 置疑數(shù)據(jù)庫 Rebuild Log on (name=SuspectDB_log,filename=’D:/Log/置疑數(shù)據(jù)庫_log.LDF’) go alter database 置疑數(shù)據(jù)庫 set multi_user goDBCC CHECKDB('置疑數(shù)據(jù)庫') goSQL 2008 質(zhì)疑修復(fù)
一、備份“置疑”數(shù)據(jù)庫的數(shù)據(jù)文件,因?yàn)槿罩疚募?ldf出錯(cuò),可以只備份.mdf文件。
二、打開SQL Server Management Studio,刪除“置疑”數(shù)據(jù)庫,如果提示刪除錯(cuò)誤,可以重啟數(shù)據(jù)庫服務(wù)器,然后再試。
三、重新使用server包創(chuàng)建hbposv10空庫
四、停止數(shù)據(jù)庫服務(wù)器
五、將剛才新建數(shù)據(jù)庫生成的數(shù)據(jù)庫的日志文件hbposv10_log.ldf刪除,用要恢復(fù)的數(shù)據(jù)庫.mdf文件覆蓋剛才生成的數(shù)據(jù)庫數(shù)據(jù)文件hbposv10_data.mdf。
六、啟動(dòng)數(shù)據(jù)庫服務(wù)器。此時(shí)會(huì)看到數(shù)據(jù)庫hbposv10的狀態(tài)為“置疑”。這時(shí)候不能對此數(shù)據(jù)庫進(jìn)行任何操作。
七、更改庫狀態(tài)
use master alter database hbposv10 set emergencyalter database hbposv10 set single_user with rollback immediate go use master go --重建log日志 alter database hbposv10 Rebuild Log on (name=SuspectDB_log,filename='C:\Program Files\Microsoft SQL Server\MSSQL10_50.MYSQLSERVER\MSSQL\DATA\hbposv10_log.ldf') goalter database hbposv10 set multi_user go八、檢查并修復(fù)數(shù)據(jù)庫
--檢查數(shù)據(jù)庫,如沒有錯(cuò)誤就不用執(zhí)行下面語句 DBCC CHECKDB('hbposv10') go --切換單用戶模式 EXEC sp_dboption 'hbposv10', 'single user', 'TRUE' go --修復(fù)數(shù)據(jù)庫,修復(fù)完后再檢查數(shù)據(jù)庫 DBCC CHECKDB ('hbposv10','repair_rebuild') Go --上面修復(fù)不行,再執(zhí)行下面修復(fù) DBCC CHECKDB ('hbposv10','repair_allow_data_loss') Go --修復(fù)完成切換多用戶模式 EXEC sp_dboption 'hbposv10', 'single user','FALSE' go--修復(fù)索引自增列 use hbposv10----門店用 use hbposv10_branch go declare @tablename varchar(100) declare test_cur cursor for select object_name(id) from syscolumns where status=128 open test_cur fetch test_cur into @tablename while @@fetch_status=0 begin DBCC CHECKIDENT (@tablename, RESEED) fetch test_cur into @tablename end close test_cur DEALLOCATE testdb_curuse hbposv10----門店用 use hbposv10_branch go declare @tablename varchar(100) declare test_cur cursor for select object_name(id) from syscolumns where status=128 open test_cur fetch test_cur into @tablename while @@fetch_status=0 begin DBCC CHECKIDENT (@tablename, RESEED) fetch test_cur into @tablename end close test_cur deallocate test_cur go總結(jié)
以上是生活随笔為你收集整理的SQL 2005/2008质疑修复的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: sql2000 数据库置疑解决
- 下一篇: 第一周内容