食通天SQL SERVER数据库置疑及修复

合集下载

SQL数据库置疑解决方案(原因、预防、修复)附图

SQL数据库置疑解决方案(原因、预防、修复)附图

S Q L数据库置疑解决方案(原因、预防、修复)附图-CAL-FENGHAI-(2020YEAR-YICAI)_JINGBIANSQL数据库置疑解决方案一、数据库置疑产生的原因1、SQL Server所在分区空间是否够?数据库文件大小是否达到最大文件限制?FAT32的格式只支持4G以内的文件。

2、数据库文件损坏或被非正常删除时出现这种情况。

3、病毒防火墙的扫描也会引起数据库置疑。

4、当SQL Server启动时,将会尝试获得对数据库文件的排他访问权,如果此时该文件被其他程序占用,或者遗失,数据库将会被标记为置疑。

5、电脑非法关机也会造成数据库置疑。

6、电脑磁盘有坏道有可能造成数据库置疑。

二、数据库置疑的预防1、数据库存放的盘符,空间是否够大,经常检查盘符的空间。

2、数据库存放的盘符的格式设置为NTFS格式。

3、进行病毒清除时,尽量把SQL服务停掉,再进行检查。

4、尽量减少非正常关机。

5、建议客户购买后备电源。

6、给客户实施软件之后一定要做好自动备份。

7、建议客户每隔一定时间手动备份一次。

三、数据库置疑的修复1、正常的备份、SQL数据库恢复方式正常方式下,我们要备份一个数据库,首先要先将该数据库从运行的数据服务器中断开,或者停掉整个数据库服务器,然后复制文件。

卸下数据库的命令:Sp_detach_db 数据库名连接数据库的命令:Sp_attach_db或者sp_attach_single_file_dbs_attach_db [@dbname =] ′dbname′, [@filename1 =] ′filename_n′ [,...16]sp_attach_single_file_db [@dbname =] ′dbname′, [@physname =] ′physical_name′使用此方法可以正确恢复SQL Sever7.0和SQL Server 2000的数据库文件,要点是备份的时候一定要将mdf和ldf两个文件都备份下来,mdf文件是数据库数据文件,ldf是数据库日志文件。

数据库置疑_及修复

数据库置疑_及修复

Sqlserver 数据库823错误(置疑)的解决方案一、SQL-Server数据库置疑:1、异常情况:服务器在正常运行的情况下突然断电,导致数据库文件损坏,具体表现是:数据库名后面有“(置疑)”字样。

2、异常分析:关于823错误的SQL-SERVER 中的帮助:================================错误823严重级别24消息正文在文件%4的偏移量,%3的索引,%2过程中,检测到I/O 错误%1。

解决办法:准备工作:①停止sql server服务,找到置疑库的mdf,ldf文件复制出来,这里假设叫kmcyV51_data.mdf(ldf),并与企业管理器中删除该数据库;②用KM安装包下db_setup.exe建立一个空库(名称和质疑数据库名一致kmcyv51),选择服务器节点,右键停止数据库服务,把损坏的数据库文件kmcyv51_Data.mdf覆盖刚才新建数据库目录下,同时删除kmcy_v51_log.LDF文件;右键节点启动数据库服务,发现数据库名kmcyv51后面有“置疑”字样。

打开SQL自带查询分析器,在master数据库分别执行如下SQL语句:(注意更改数据库名)use masterexec sp_configure 'allow updates',1 RECONFIGURE WITH OVERRIDE /* 打开修改系统表开关*/update sysdatabases set status=32768 where name = 'kmcyv51' /* 设置紧急状态*/sp_dboption 'kmcyv51', 'single user', 'true' /*启用单用户*/DBCC REBUILD_LOG ('kmcyv51','E:\km软件_data\KmcyV51_Log.LDF') /* 重建LDF文件*/update sysdatabases set status=28 where name= 'kmcyv51' /* 设置正常状态*/--或者update sysdatabases set status = 16 where name = 'kmcyv51'RESTORE DATABASE kmcyv51 WITH RECOVERY /* 恢复数据库*/exec sp_configure 'allow updates',0 RECONFIGURE WITH OVERRIDE /* 关闭修改系统表开关*/sp_dboption 'kmcyv51', 'single user', 'false' /* 关闭单用户模式*/如果问题依然存在,最笨的一个方法就是新建另一个数据库,把原数据库各个表的数据导出到新建数据库表中。

SQLServer2000数据库置疑的解决方法

SQLServer2000数据库置疑的解决方法

SQLServer2000数据库置疑的解决方法sql2000中MSDB数据库置疑状态的解决方法问题:我的SQL Server 2000的MSDB数据库,因为不正常关机,造成了置疑状态,请问采用什么方法能够弥补,解决方法一:你可以采用以下的代码进行修复: USE MASTERGOSP_CONFIGURE 'ALLOW UPDATES',1RECONFIGURE WITH OVERRIDEGOUPDATE SYSDATABASES SET STATUS =32768 WHERE NAME='msdb' Gosp_dboption 'msdb', 'single user', 'true'GoDBCC CHECKDB('msdb')Goupdate sysdatabases set status =28 where name='msdb' Gosp_configure 'allow updates', 0reconfigure with overrideGosp_dboption 'msdb', 'single user', 'false'Go解决方法二:MSDB数据库解决过程难点:由于MSDB数据库不能删除,将其文件拷出来,再次附加数据库,但新的不能同名,遇到了困难。

附加数据库不能叫MSDB,也就是1:先停止整个数据库,将该数据库的文件msdbdata.mdf和msdblog.ldf拷贝粘贴出来到另一个目录下。

2:将以上的文件再拷贝到另一个目录下,也就是说复制两次。

3:选择数据库右击鼠标 --》所有任务--》附加数据库将复制出的一个备份文件附加上去,其中,数据库名称叫MSDB1,用户是SA或ADMINISTRATOR。

4:将MSDB1数据库备份,备份成一个文件,当时我的叫MSDB。

SQL数据库置疑的解决方法

SQL数据库置疑的解决方法

SQL2000数据库置疑的解决方法首先,在任何操作之前,必须要备份数据库(重要)一、分离数据库1、点击“程序》Microsoft SQL Server》企业管理》”,打开企业管理器2、展开服务器组,然后展开服务器,选中要分离的数据库3、点击鼠标右键“所有任务》分离数据库”,出现如下窗口4、点击确定,该选定的数据库就被分离。

5.分离后,把原数据库里面.MDF(主数据文件).LDF(事务日志文件)这两个文件复制到目标盘下,例:D盘下注意事项,只有“使用本数据库的连接”数为0时,该数据库才能分离。

所以分离数据库时尽量断开所有对要分离数据库操作的连接,如果还有连接数据库的程序,会出现数据库的连接状态窗口,显示正在连接此数据库的机器以及名称,点击清除按钮将从服务器强制断开现有的连接。

二、附加数据库1、在附加数据库之前,首先要移动数据库文件在附加数据库之前,您必须将与数据库关联的 .MDF(主数据文件).LDF(事务日志文件)这两个文件复制到目标硬盘下,或是同一服务器的不同硬盘目录下。

这两个文件一般位于C:\Program Files\Microsoft SQL Server\MSSQL\Data目录下。

2、点击“程序》Microsoft SQL Server》企业管理》”,打开企业管理器3、展开服务器组,然后展开服务器4、右击"数据库",然后选择“所有任务》附加数据库”,弹出窗口5、输入要附加的数据库的MDF名称。

如果不确定文件位于何处,单击浏览("...")搜索。

若要确保指定的 MDF 文件正确,请单击"验证"。

在"附加为"框内,输入数据库的名称。

数据库名称不能与任何现有数据库名称相同。

指定数据库的所有者6、单击"确定"按钮。

新附加的数据库的数据库节点即创建在"数据库"文件夹中重启双机1.此时数据库分离,附加完成,必须重启一次双机修复置疑1,双机重启后,数据库置疑下面所有修复置疑的语法,在没有特别提到时,默认数据库都请选择(Master)数据库)2,修复置疑(必须在SQL的查询分析器中才能进行数据修复置疑工作)A、打开查询分析器,当数据置疑之后在查询分析器中是看不到置疑的数据库名称的,所以进入查询分析器之后,所选数据库默认(Master)数据库即可。

sql server数据库被置疑解决方法(The SQL Server database is the solution to doubt)

sql server数据库被置疑解决方法(The SQL Server database is the solution to doubt)

sql server数据库被置疑解决方法(The SQL Server database is thesolution to doubt)First, make sure that you have backed up the.Mdf and.Ldf files.2. create a database with the same name in SQL Server, and then stop the SQL Server service.3. overwrite the.Mdf and.Ldf files of the new database with the original.Mdf and.Ldf files.4. restart the SQL Server service, which should see the database in doubt (Suspect) state.5. in the SQL query analyzer, execute the following command to allow updating of the system tables:Use masterGoSp_configure 'allow updates', 1Reconfigure with overrideGo6. place this database as an emergency mode:Update, sysdatabases, set, status = 32768, where, name='db_name'Go7. check the errors in the database using the DBCC CHECKDB command:DBCC CHECKDB ('db_name')GO8. if the DBCC CHECKDB command fails, go to the tenth step, or you will first set the database in a single user mode, and then try to fix it:Sp_dboption'db_name',' single user ',' true 'DBCC CHECKDB ('db_name', REPAIR_ALLOW_DATA_LOSS)GOIf the DBCC CHECKDB ("db_name", "REPAIR_ALLOW_DATA_LOSS") command is prompted to indicate that the database is not in a single user mode, restart the SQL Server service, and then proceed with the attempt.9. if the DBCC CHECKDB ('db_name', REPAIR_ALLOW_DATA_LOSS) command fails, go to the tenth step, otherwise the database error will be repaired successfully:Rerun the DBCC CHECKDB ('db_name') command to make sure there are no errors in the database.Clear the query status of the database:sp_resetstatus'db_name'Clear the single user mode state of the database:sp_dboption'db_name',' single user ',' false 'Restart the SQL Server service and, if everything is OK, the database has been successfully restored.10. if the above steps do not solve the problem, please refer to the document in the attached file and try to restore the data in the database by rebuilding the transaction log.If you have only MDF files, the problem is more complex, and we need to rebuild the transaction log directly:1. create a database with the same name in SQL Server, and then stop the SQL Server service.2. overwrite the new.Mdf file with the original LDF file and delete the log file (.Ldf).3. start the SQL Server service and set the database as an emergency mode (ibid.: steps 5 and 6).4. stop and restart the SQL Server service.5. perform the following commands to rebuild the database log file: (here is an example that you will need to use your actual database name)DBCC REBUILD_LOG ('cas_db','D:\cas_db\cas_db_Log.LDF')6. reset the database to a single user mode.The Sql Server database is the solution to doubtEnvironment WIN2000, SQL, server2kProblem: when a database is generally updated, queries are suddenly "doubted" and cannot be used any moreYou can't solve the problem by dealing with it yourself:1, close the SQL Server database, the corresponding database.Mdf.Ldf file moved to other directories, delete the original database2. Start the SQL Server database and create a new database with the same name,3, close the SQL Server database, with the original database.Mdf.Ldf file overwrite new database corresponding file. The problem still exists, it doesn't work.Search for information and solve problems through results online:1, close the SQL Server database, will be questioned database file (.Mdf.Ldf) copy back up.2. Open the SQL Server database and create a new database with the same name,3, close the SQL Server database and overwrite the new database's same name file with the backup.Mdf file4. Open the SQL Server database and execute the following statement in the query analyzer, allowing direct modification of the system directoryUse masterGoSp_configure,'allow, updates', 1GoReconfigure with overrideGoUpdate, sysdatabases, set, status=-32768, where, dbid=DB_ID ('newdb')5. Rebuild the new database logDBCC rebuild_log ('newdb','C:\Program, Files\Microsoft, SQL, Server\MSSQL\Data\newdb_log.ldf')With this step in progress, you may find that the data is ina read-only / offline / state, and proceed to the following operation6, DBCC checkDBCC CHECKDB ('newdb')When you go to this section, you may find that there are errors. You can look at some of the data tables of the prompt. If it is not a critical table, you can let go first.7, set the database as a normal stateSp_dboption,'newdb','dbo, use, Only','false'8, close the database directly modify permissions, do not allow direct modification of the system directorySp_configure,'allow, updates', 0GoReconfigure with overrideGoOf course, my data did not recover at the first step. I've done it all over again, and my database has been restored to normal, and I feel very happy.Total feel, personal feeling, the database was questioned,should be because the database log is too large, the database log has reached 15G. But I'm not sure yet. Keep studying.Come on.SQL2000 database query solution 2009-03-21 09:12 follows the following steps:1. create a new database with the same name2. stop SQL server again3. overwrite the new database file with the same name by using the backup database MDF file4. restart SQL Server5., when you open the enterprise manager, the new database of the same name will appear doubt, first ignore, execute the following statement (pay attention to modify the database name)USE MASTERGOSP_CONFIGURE,'ALLOW, UPDATES', 1, RECONFIGURE, WITH, OVERRIDEGO"UPDATE SYSDATABASES SET STATUS =32768 WHERE NAME='database name'GoSp_dboption 'database name', ''single user' ',''true''GoDBCC CHECKDB ('database name')Go"Update sysdatabases set status =28 where name='database name'GoSp_configure,'allow, updates', 0, reconfigure, with, overrideGoSp_dboption 'database name', ''single user' ',''false''GoDatabase query recovery classic/********************************************************** ******** this kind of fault is usually caused by disk read and write problems.* the following statement is the SQL that fixes the database of the headquarters. If you need to fix the database of the segment, change'hbposv5'to'hbposv5_branch'* supermarket star system is implemented directly* shortcut, Invoicing series, pleasechange'hbposv5'to'isd2001v3', and if it is subsection, change to'isd2001v3_branch'* business series, please change'hbposv5'to'isd2001v4', if the segment, changed to'isd2001v4_branch'*********************************************************** *******/Please perform the following statements in the query analyzer. Disconnect all other database connections before execution. It's better to disconnect the network cableUSE masterGoSingle user modeEXEC, sp_dboption,'hbposv5','single, user','TRUE'Go-- database checkingDBCC CHECKDB ('hbposv5')Go- if you return the result with a red prompt text that indicates an error in the database, you need to fix it-- database repairDBCC CHECKDB ('hbposv5', repair_rebuild)GoAgain, database check, and if there is no red prompt text in the return result, the repair is successful;DBCC CHECKDB ('hbposv5')GoOtherwise it means higher levels of repair are required. Try changing the'repair_rebuild'of the repair statementto'repair_allow_data_loss', and then check the database again.- if there are any errors that have not been repaired,Before you quit, be sure to execute the following statement and return to the multi-user modeEXEC, sp_dboption,'hbposv5','single, user','FALSE'GoDatabase query processingStep 1:Create a new database named as the name of the original database.Step 2:Stop SQL ServerStep 3:Replace the old database's MDF file with the corresponding MDF file of the new database and delete the LDF file.Step 4:Restart the SQL Server service, and then run the following command:Use MasterGoSp_configure,'allow, updates', 1Reconfigure with overrideGoBegin tranUpdate, sysdatabases, set, status = 32768, where, name='hbposv5'--Verify, one, row, is, updated, before, committingCommit tranStep 5:Stop SQL and restart the SQL Server service,Then run the following command:DBCC TRACEON (3604)DBCC REBUILD_LOG('db_name','c:\mssql7\data\hbposv5_log.ldf')GoStep 6:Stop SQL, then restart the SQL Server service, and then run: Use masterUpdate, sysdatabases, set, status = 8, where, name ='hbposv5'GoSp_configure,'allow, updates', 0Reconfigure with overrideGoStep 7:Run DBCC CHECKDB (hbposv5) to check the integrity of the databaseNote: all must be replaced with the actual database name.。

SQL置疑数据库处理方法

SQL置疑数据库处理方法

SQL置疑数据库处理方法:1.新建一个同名的数据库。

2.停掉sql server(注意不要分离数据库)。

3.用原数据库(质疑的那个)的数据文件覆盖掉这个新建的数据库文件。

(以上1、2、3步骤是针对把质疑数据库文件放到另外的计算机处理的情况,如果就在本机处理,可以省略,但在处理前一定要注意备份数据库文件。

)4.再重启sql server。

5.此时打开企业管理器时会出现置疑,先不管,执行下面的语句(注意修改其中的数据库名)。

USE MASTERGOSP_CONFIGURE 'ALLOW UPDATES',1 RECONFIGURE WITH OVERRIDEGOUPDATE SYSDATABASES SET STATUS =32768 WHERE NAME='置疑的数据库名'Gosp_dboption '置疑的数据库名', 'single user', 'true'GoDBCC CHECKDB('置疑的数据库名')Goupdate sysdatabases set status =28 where name='置疑的数据库名'Gosp_configure 'allow updates', 0 reconfigure with overrideGosp_dboption '置疑的数据库名', 'single user', 'false'Go6.完成后一般就可以访问数据库中的数据了;这时,数据库本身一般还要问题,解决办法是利用数据库的脚本创建一个新的数据库,并将数据导进去就行了,或者把数据库导成一个新库来代替旧库,先把数据导出,然后重启计算机后再导入就OK了。

步骤如下:企业管理器--右键你的数据库--所有任务--导出数据(导入数据)--目标标数据库选择新建--选择"在两个sql数据库之间复制对象和数据"--把"包含扩展属性"选上,其他的根据需要选择--最后完成。

sqlserver2000数据库置疑的4种解决方法

sqlserver2000数据库置疑的4种解决方法

s q l s e r v e r2000数据库置疑的4种解决方法本页仅作为文档封面,使用时可以删除This document is for reference only-rar21year.Marchsqlserver2000 数据库置疑的4种解决方法方法一:1.停止SQL Server的服务,然后备份MS SQL Server的安装目录下的\data 子目录.注意:整个目录目录备份或只备份data目录下置疑数据库的两个文件,一个数据文件,一个(也有可能非此命名),同时查看磁盘空间是否有足够的空间;2.启用SQL Server的服务。

打开查询分析器(Query Analyzer)的工具,以用户sa登录;3.输入如下指令后点工具栏上的绿色箭头运行(快捷键F5),use mastergosp_resetstatus dbnamego4.运行完毕后退出此工具,停止SQL Server的服务.5.在MS SQL Server的安装目录下,有一个\data子目录,其中存放数据文件,包括SQL Server和本系统的数据文件,删除置疑数据库的日志文件(也有可能非此命名).6.启动SQL Server的服务.7.打开企业管理器(Enterprise Manager)的工具,查看数据库(database)节点下的dbname是否恢复。

注:请将 dbname 换成你的数据库名称.方法二1.查看磁盘空间,保证存放数据库的磁盘有足够的剩余空间;2.打开SQL Server的查询分析器(Query Analyzer),以用户 sa 登录;3.输入如下指令后点工具栏上的绿色箭头运行(快捷键F5),运行完毕后退出此工具.use mastergosp_resetstatus dbnamego4.停止SQL Server 的服务,再重新启动SQL Server 服务.5.打开SQL Server 的查询分析器(Query Analyzer),以用户 sa 登录。

sql server 数据库质疑(挂起)修复步骤

sql server 数据库质疑(挂起)修复步骤

数据库修复步骤
1.将已破坏的老数据库更名如Baddb_Data.Mdf ==>Baddb_Data.Md_ ,并在原来位置新建一同
名数据库如Baddb_Data.Mdf .
2. 停止SQL, 将新数据库更名(Baddb_Data.Mdf ==> Baddb_Data.Md2),
待修复老数据库更名为原先名称Baddb_Data.Md_ ==> Baddb_Data.Mdf
3.启动SQL , 并进入查询分析器中, 执行如下命令:
USE MASTER
sp_configure 'allow', 1
reconfigure with override
update sysdatabases set status = 32768 where name = 'Baddb'
4. 把LDF文件改名,再执行
DBCC REBUILD_LOG ('Baddb', 'E:\posdb\Baddb_Log.LDF' )
5. 恢复数据库紧急模式
update sysdatabases set status = 0 where name = 'Baddb'
6. 执行
restore database Baddb WITH RECOVERY
sp_configure 'allow', 0
reconfigure with override
7. 检查数据库看看有没有错误, 应该可以看到数据了
DBCC CHECKDB ('Baddb')
如以上还是不行,试把数据库设为紧急模式,再把数据导出到一个新的数据库(如有坏区)。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
步骤6:
停止SQL然后重新启动SQL Server服务,然后运行:
use master
update sysdatabases set status = 8 where name = 'hbfsv8'
Go
sp_configure 'allow updates', 0
reconfigure with override
USE master
Go
--单用户模式
EXEC sp_dboption 'hbfsv8', 'single user', 'TRUE'
go
--数据库检查
DBCC CHECKDB ('hbfsv8')
Go
--如果返回结果出现了红色的提示文字,说明数据库中存在错误,需要修复
--数据库修复
DBCC CHECKDB ('hbfsv8',repair_rebuild)
食通天SQL SERVER数据库置疑及修复
数据库置疑处理
提要:在数据库置疑或者修复的处理过程中,须先将文中的数据库更改为真实的数据库名称.
数据库置疑修复处理完成后,需执行第二步骤,使用DBCC语句对数据库进行检测并修复错误.
对于损坏的数据库,可参照数据库修复处理方法进行处理.
步骤1:
停止SQL服务管理器,将原数据文件拷贝出来进行备份,然后将原数据库删除,使用思迅数据库安装程序创建一个新的数据库。
Go
begin tran
update sysdatabases set status = 32768 where name = 'hbfsv8'
--Verify one row is updated before committing
commit tran
步骤5:
停止SQL然后重新启动SQL Server服务,然后运行如下命令:
步骤2:
停止SQL Server服务管理器
步骤3:
用备份出来的老数据库的MDF文件替换新数据库相应的MDF文件,并把LDF文件删除。
步骤4:
重新启动SQL Server服务,然后运行如下命令:
Use Master
Go
sp_configure 'allow updates', 1
reconfigure with override
DBCC TRACEON(3604)
DBCCREBUILD_LOG('db_name','C:\ProgramFiles\MicrosoftSQL Server\MSSQL\Data\hbfsv8_log.ldf')
Go
--注:此处的db_name一定要更换为需要修复的数据库名称,比如此实例中的hbfsv8
Go
步骤7:
运行dbcc checkdb(hbfsv8)检查数据库的完整性
数据库修复
/*****************************************************************
*本语句可以多次执行,一直到没有红色文字出现,则修复成功
*这类故障是一般是由于磁盘读写问题造成的。
* 'hbfsv8据库的SQL,如需要修复分部的数据库,请将'hbfsv8'改为'hbfsv8_branch'
******************************************************************/
--请在查询分析器中执行下列语句.执行前断开其它所有数据库连接,最好是断开网线
--退出前请一定要执行以下语句返回到多用户模式
EXEC sp_dboption 'hbfsv8', 'single user','FALSE'
go
Go
--再次数据库检查,如果返回结果中没有了红色的提示文字,说明修复成功;
DBCC CHECKDB ('hbfsv8')
Go
--否则意味着还需要更高级别的修复;尝试将上面修复语句的'repair_rebuild'换为'repair_allow_data_loss'再试,之后再次检查数据库。
--如果还有错误未修复,
相关文档
最新文档