资源描述:
《sql server数据库被置疑解决方法(the sql server database is the solution to doubt)》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、sqlserver数据库被置疑解决方法(TheSQLServerdatabaseisthesolutiontodoubt)First,makesurethatyouhavebackedupthe.Mdfand.Ldffiles.2.createadatabasewiththesamenameinSQLServer,andthenstoptheSQLServerservice.3.overwritethe.Mdfand.Ldffilesofthenewdatabasewiththeoriginal.Mdfand.Ld
2、ffiles.4.restarttheSQLServerservice,whichshouldseethedatabaseindoubt(Suspect)state.5.intheSQLqueryanalyzer,executethefollowingcommandtoallowupdatingofthesystemtables:UsemasterGoSp_configure'allowupdates',1ReconfigurewithoverrideGo6.placethisdatabaseasanemergen
3、cymode:Update,sysdatabases,set,status=32768,where,name='db_name'Go7.checktheerrorsinthedatabaseusingtheDBCCCHECKDBcommand:DBCCCHECKDB('db_name')GO8.iftheDBCCCHECKDBcommandfails,gotothetenthstep,oryouwillfirstsetthedatabaseinasingleusermode,andthentrytofixit:Sp
4、_dboption'db_name','singleuser','true'DBCCCHECKDB('db_name',REPAIR_ALLOW_DATA_LOSS)GOIftheDBCCCHECKDB("db_name","REPAIR_ALLOW_DATA_LOSS")commandispromptedtoindicatethatthedatabaseisnotinasingleusermode,restarttheSQLServerservice,andthenproceedwiththeattempt.9.
5、iftheDBCCCHECKDB('db_name',REPAIR_ALLOW_DATA_LOSS)commandfails,gotothetenthstep,otherwisethedatabaseerrorwillberepairedsuccessfully:ReruntheDBCCCHECKDB('db_name')commandtomakesuretherearenoerrorsinthedatabase.Clearthequerystatusofthedatabase:sp_resetstatus'db_
6、name'Clearthesingleusermodestateofthedatabase:sp_dboption'db_name','singleuser','false'RestarttheSQLServerserviceand,ifeverythingisOK,thedatabasehasbeensuccessfullyrestored.10.iftheabovestepsdonotsolvetheproblem,pleaserefertothedocumentintheattachedfileandtryt
7、orestorethedatainthedatabasebyrebuildingthetransactionlog.IfyouhaveonlyMDFfiles,theproblemismorecomplex,andweneedtorebuildthetransactionlogdirectly:1.createadatabasewiththesamenameinSQLServer,andthenstoptheSQLServerservice.2.overwritethenew.Mdffilewiththeorigi
8、nalLDFfileanddeletethelogfile(.Ldf).3.starttheSQLServerserviceandsetthedatabaseasanemergencymode(ibid.:steps5and6).4.stopandrestarttheSQLServerservice.5.performthefollowingcommands