SQL Server 2008数据库被标记为可疑的解决方法
SQLSERVER2008 数据库可疑的解决步骤

1 把问题数据库备份后直接删除停掉SQLSERVER服务,把服务器上出问题的数据库, 假设名称为 ErrorDB的数据库文件及日志文件备份到其他目录,然后直接将其删除,把其数据库文件及日志文件也删除2 新建同名数据库启动SQLSERVER服务,新建同名数据库ErrorDB,文件目录和日志和原来一致3 用备份的数据库文件替换新的数据库文件停掉SQLSERVER服务,把备份的数据库文件替换新的数据库文件(只替换数据库文件,不替换日志文件)启动SQLSERVER服务,打开数据库,这时数据库应该是不能访问的-------------------设置应急模式、单用户模式、检查修复数据,取消单用户模式----------------------4 将数据库设置为应急状态alter database ErrorDB set emergency执行后,为了保险起见,重新停止、开启的SQLSERVER服务再打开数据库,已经可以看到里面的内容了,如表,视图,存储过程等数据库名称后有紧急标志,能看到数据库结构,但无法进行备份等操作5 将数据库设置为单用户模式ALTER DATABASE ErrorDB SET SINGLE_USER6 对数据库进行检查修复dbcc checkdb(EIMSDb,REPAIR_ALLOW_DATA_LOSS)dbcc checkdb(EIMSDb,REPAIR_REBUILD)操作后,仍然停止启动SQLSERVER服务(不确定是否需要,我只是为了想无干扰查看执行后的数据库状况)重新打开数据库,已经是正常状态了,没有应急提示了7 取消单用户模式exec sp_dboption EIMSDb, N'single', N'false'至此,数据库恢复完毕,对数据库进行BAK。
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是数据库日志文件。
sql server 数据库异常的解决方法

SQL Server数据库异常是常见的技术问题,以下是一些可能的解决方法:
检查错误日志:SQL Server的错误日志是解决问题的关键。
出现异常时,首先应查看错误日志,了解详细的错误信息。
备份和恢复:定期备份数据库是预防数据丢失的有效方法。
如果出现数据损坏或丢失,可以尝试使用备份进行恢复。
检查数据库连接:确保应用程序能够正常连接到SQL Server。
如果连接出现问题,可以检查网络连接、防火墙设置、SQL Server配置等。
优化查询性能:如果查询性能下降,可能是因为表结构不合理、索引失效、数据量过大等。
可以考虑优化查询语句、重建索引、清理历史数据等。
检查磁盘空间:SQL Server数据库需要足够的磁盘空间。
如果磁盘空间不足,可能导致数据库无法正常运行。
需要定期检查服务器磁盘空间,并及时清理不必要的文件。
更新和修复:如果是SQL Server的bug导致的异常,可能需要安装最新的补丁或升级到新版本。
同时,也可以考虑使用修复工具来修复数据库损坏。
联系技术支持:如果自己无法解决问题,可以联系Microsoft的技术支持或社区寻求帮助。
在处理SQL Server数据库异常时,应保持冷静,根据错误信息进行排查。
同时,预防总比治疗更重要,平时应做好数据库的维护和管理,避免出现异常。
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 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 server 2008 数据库置疑的处理办法

SQL server 2008 数据库置疑的处理办法1 把问题数据库备份后直接删除停掉SQLSERVER服务,把服务器上出问题的数据库, 假设名称为ErrorDB的数据库文件及日志文件备份到其他目录,然后直接将其删除,把其数据库文件及日志文件也删除2 新建同名数据库启动SQLSERVER服务,新建同名数据库ErrorDB,文件目录和日志和原来一致3 用备份的数据库文件替换新的数据库文件停掉SQLSERVER服务,把备份的数据库文件替换新的数据库文件(只替换数据库文件,不替换日志文件)启动SQLSERVER服务,打开数据库,这时数据库应该是不能访问的-------------------设置应急模式、单用户模式、检查修复数据,取消单用户模式----------------------4 将数据库设置为应急状态alter database ErrorDB set emergency执行后,为了保险起见,重新停止、开启的SQLSERVER服务再打开数据库,已经可以看到里面的内容了,如表,视图,存储过程等数据库名称后有紧急标志,能看到数据库结构,但无法进行备份等操作5 将数据库设置为单用户模式ALTER DATABASE ErrorDB SET SINGLE_USER6 对数据库进行检查修复dbcc checkdb(EIMSDb,REPAIR_ALLOW_DATA_LOSS)dbcc checkdb(EIMSDb,REPAIR_REBUILD)操作后,仍然停止启动SQLSERVER服务(不确定是否需要,我只是为了想无干扰查看执行后的数据库状况)重新打开数据库,已经是正常状态了,没有应急提示了7 取消单用户模式exec sp_dboption EIMSDb, N'single', N'false'至此,数据库恢复完毕,对数据库进行BAK重启网站,访问正常。
SQL数据库置疑解决方案(原因、预防、修复)附图

SQL数据库置疑解决方案一、数据库置疑产生的原因1、SQL Server所在分区空间是否够?数据库文件大小是否达到最大文件限制?FAT32的格式只支持4G以内的文件。
2、数据库文件损坏或被非正常删除时出现这种情况。
3、病毒防火墙的扫描也会引起数据库置疑。
4、当SQL Server启动时,将会尝试获得对数据库文件的排他访问权,如果此时该文件被其他程序占用,或者遗失,数据库将会被标记为置疑。
5、电脑非法关机也会造成数据库置疑。
6、电脑磁盘有坏道有可能造成数据库置疑。
二、数据库置疑的预防1、数据库存放的盘符,空间是否够大,经常检查盘符的空间。
2、数据库存放的盘符的格式设置为NTFS格式。
3、进行病毒清除时,尽量把SQL服务停掉,再进行检查。
4、尽量减少非正常关机。
5、建议客户购买后备电源。
页脚内容16、给客户实施软件之后一定要做好自动备份。
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是数据库日志文件。
例子:假设数据库为pdm,其数据文件为pdm_data.mdf,日志文件为pdm_log.ldf。
解决SQLSERVER 2008系统数据库MSDB “可疑”的方法

解决SQL Server2008 msdb可疑的数据库的方法请参考文章/sqlservertip/2571/restoring-sql-server-system-databases-msdb-and-model/ProblemDue to a recent rebuild of the master database for a SQL Server instance, I now need to restore the msdb and model databases. In this tip we walk through the process that you need to follow to restore the model and msdb databases successfully.SolutionBefore we get started, let's quickly discuss what the msdb and model databases are used for.∙The msdb database contains scheduled jobs, alerts and backup history therefore a proper backup plan should be implemented for the msdb system database.∙The model database is the blue print for creating any new user database for that particular instance of SQL Server. DBAs can modify the model database with whateversettings that are required and when a new user database is created it will reflect theconfiguration of the model database. If the model database has been modified then itshould be backed up.Hence both the msdb and model databases may need to be recovered in scenarios like database corruption, a rebuild of the master database or after a new server configuration. The restore process of msdb or model demands additional considerations than that of a user databases. The restore process may get complicated if versions are not tracked and exclusive access is not ensured in all aspects. In the next sections we will go through the restore process for the msdb and model databases.Note: this exercise was performed on SQL Server 2005, but the same rules would also be applied on SQL Server 2005 and onwards.Backup msdbUse the following command to create a full backup of the msdb database using T-SQL commands. You will need to modify the script to use a validbackup path. You can perform the same process for the model database as well.--Script 1: Create backup of msdbUSE [master]GOBACKUP DATABASE [msdb]TO DISK = N'E:\MSDB_Backup.Bak'WITH INIT,NAME = N'msdb Backup for MSSQLTips Demo'GOAfter this is complete we have a full backup that can be restored.Prepare for restoreTo ensure we have a smooth restore we need to follow these steps.∙Get the version of destination server∙Get the version of source server on which the backup was created∙Match the versions for the source and destination servers∙Ensure exclusive access to the databaseThe term source server here refers to the server on which the backup was created and destination server is where the restore will occur.Get version of destination serverThe versions of SQL Server need to be the same for the source and destination when restoring the msdb or model database. If the versions for the source and destination servers do not match then the restore will fail as shown below:Msg 3168, Level 16, State 1, Line 1The backup of the system database on the device E:\MSDB_Backup.Bak cannot be restored because it was created by a different version of the server (9.00.1399) than this server (9.00.5000).Msg 3013, Level 16, State 1, Line 1RESTORE DATABASE is terminating abnormally.In the case of a mismatch, the version of SQL Server for the destination needs to be manipulated by installing or removing service packs.Here are the three ways to get the version for the SQL Server database engine.Using SSMS Object ExplorerConnect to a SQL Server instance through SSMS and find the SQL Server version in object explorer as shown below.Using SERVERPROPERTY system functionThe SERVERPROPERTY system function can be used for retrieving SQL Server version information to get edition and service pack information.Using @@VersionThe SQL Server version can also be retrieved by using @@Version. It can be used in a simple select statement as shown below.Get version of source server on which backup was createdNow we need to get the version of the source server on which the backup was created. The best way to do this is to get the information from the backup file itself as shown below using the RESTORE HEADERONLY command.-- Script 2: Get information of backup fileRESTORE HEADERONLYFROM DISK = N'E:\MSDB_Backup.Bak'GOAbove is the partial output from the command and we can see the SoftwareVersionMajor, SoftwareVersionMinor andSoftwareVersionBuild. These three values equate to the output from the other commands we look at earlier.Match the versions of source and destination serverIn our case we have version 9.0.5000 which matches both the source and destination servers. If this is not the case then apply or remove service packs on the destination server to match the source server. Once both versions are the same then we are ready to go further with the process.Following is a mapping of version codes for SQL Server 2005 and onwards from Microsoft SQL Server support.Ensure exclusive accessExclusive access for the database is required just like restoring any database, but for the msdb it is slightly more demanding. In the case of msdb we also have to consider the SQL Agent service. If the SQL Server agent service is running then exclusive access can not be achieved. Below we can see that the SQL Agent service is running by queryingsys.sysprocesses.So for msdb we need to stop the SQL Agent service to make sure we can get exclusive access. This can be done by right clicking on SQL Server Agent and selecting Stop.Restore msdbAt this point our requirements are fulfilled and we are ready to perform the restore. Execute the following command for the restore process.--Script 3: Restore msdbUSE masterGORESTORE DATABASE [msdb]FROM DISK = N'E:\MSDB_Backup.Bak'WITH REPLACEGOThe msdb database is now restored as shown below. Now we need to put the database back in multi user (if this was changed) and start the SQL Server agent service.The same requirements and process also work for the model database except that the SQL Agent service is not an issue.Another thing to note is that you can restore msdb and model databases across editions such as Express, Developer, Standard and Enterprise. You only need to be concerned that the versions are the same.Next Steps∙As part of best practices, go through your various phases of a disaster recovery process.Manipulating system databases is an integral part of disaster recovery.∙Click here to read a tip about getting exclusive access of SQL Server databases∙Click here to read a tip about system databases in SQL Server∙Click here to read details about versions and releases of SQL Server∙Click here to read about using SERVERPROPERTY∙Click here to read about using @@Version。
SQL数据库置疑解决方法

SQL数据库置疑解决方法
一、SQL数据库置疑
1.数据库安全问题
为了保护数据库,需要确保数据库中的信息不被恶意攻击、篡改或盗窃,从而避免造成不可挽回的损失。
2.数据库可靠性问题
可靠性是指数据库系统必须在不同的时间片段可靠运行,即使是在发生系统故障的情况下,用户也能够一直获取服务。
只有数据库系统可靠性良好,才能够实现数据库系统的高安全性要求。
3.数据库性能问题
要满足用户的需求,必须保证数据库服务器能够达到最佳性能,避免出现数据库访问运行缓慢的问题,以及查询数据库时出现的查询延时、查询次数多等问题。
4.数据库维护问题
数据库系统是一个复杂的系统,在日常运行中难免会出现数据库系统故障、业务变更需求等情况。
数据库系统维护对于保证系统可靠性,提高系统性能至关重要。
1.数据库安全问题
(1)做好安全设置,为数据库设置正确的授权,只允许拥有访问权限的用户进行访问,并设置访问日志,记录访问和更改的用户,以及操作的时间等信息。
(2)定期备份数据库,将备份数据存放到安全的位置。
sqlserver数据库出现可疑错误修复方法

第一种方法:
当数据库发生这种操作故障时,可以按如下操作步骤可处理此要领,打开数据库里的
Sql
查询编辑器式
ALTER DATABASE 数据库名 SET EMERGENCY
?
使数据库变为单用户模式
启动服务
再次,打开
Sql Server 2005
时被标记为“可疑”的数据库已还原正常状态
第二种方法:
如果有数据库全备份,在其他SqlServer机器上先建一个和可疑数据库名称一样的数据库,将全备份还原到先建的数据库,再把新建数据库的ldf和mdf文件拷到可以数据库的目录下。
二、msdb系统数据库可疑
ALTER DATABASE 数据库名 SET SINGLE_USER
?
修正数据库日志重新生成,此命令检查的分配,结构,逻辑完整性和所有数据库中的对 象不正确。当您指定“REPAIR_ALLOW_DATA_LOSS”作为DBCC CHECKDB命令参数,该程序将检查和修正报告的不正确。但是,这些修正可能会导致一些数据丢失。命令:DBCC CheckDB (数据库名 , REPAIR_ALLOW_DATA_LOSS)
如果复制过来是单个用户,那么右键点这个库的属性-选项-限制访问改成MULTI_USER就可以了,目前还没出现问题,建议备份后尝试
?
使数据库变回为多用户模式
ALTER DATABASE 数据库名 SET MULTI_USER
?
开始->
运行->
输入cmd
打开DOS命令窗口,输入以下命令重启数据库服务
Net stop mssqlserver --
数据库置疑的解决方法

数据库置疑的解决方法
首先,当我们发现数据库出现问题时,我们需要及时排查可能的原因。
我们可
以通过查看数据库的日志文件和错误日志,来了解数据库最近的运行情况和可能出现的错误信息。
此外,我们还可以通过数据库管理工具来检查数据库的表结构、索引情况以及数据完整性,以确定问题的具体表现和可能的原因。
其次,针对不同的数据库问题,我们需要采取不同的解决方法。
比如,当数据
库出现性能问题时,我们可以通过优化查询语句、增加索引、分析表结构等方式来提升数据库的性能;当数据库出现数据丢失或损坏的情况时,我们可以通过备份恢复数据、修复表结构、使用数据恢复工具等方式来恢复数据的完整性。
此外,我们还需要重视数据库的安全性和稳定性。
我们可以通过加强数据库的
访问控制、定期备份数据、定期维护数据库等方式来保障数据库的安全性和稳定性。
同时,我们还可以考虑使用数据库集群、数据库镜像、数据库分区等方式来提升数据库的可用性和容错性。
最后,我们需要不断学习和积累数据库维护和故障排除的经验,以便更好地应
对各种数据库问题。
我们可以通过阅读相关的书籍和文档、参加培训课程、积极参与技术社区的讨论等方式来不断提升自己的数据库维护和故障排除能力。
总之,数据库置疑的解决方法需要我们及时排查问题、针对不同问题采取不同
的解决方法、重视数据库的安全性和稳定性,以及不断学习和积累经验。
希望以上内容能够帮助大家更好地解决数据库置疑的问题,确保数据库的正常运行和数据的完整性。
sql05 08置疑解决

关于门店数据库SQLSERVER2000/2005/2008置疑问题处理方法SQL Server2008置疑数据库解决方法1.首先确认已经备份了.mdf和.ldf文件。
2. 在SQL Server中新建一个同名的数据库,然后停止SQL Server服务。
3. 用原有的.mdf和.ldf文件覆盖新建数据库对应的.mdf和.ldf文件。
4. 重新启动SQL Server服务,这是应该会看到这个数据库处于置疑(Suspect)状态。
5. 在SQL查询分析器中执行以下命令,以允许更新系统表:use mastergosp_configure "allow updates",1reconfigurewithoverridego6. 将这个数据库置为紧急模式:update sysdatabases set status = 32768 where name="db_name"go7. 使用DBCC CHECKDB命令检查数据库中的错误:DBCC CHECKDB("db_name")GO8. 如果DBCC CHECKDB命令失败,请转至第10步,否则先将数据库置为单用户模式,再尝试对其进行修复:sp_dboption "db_name","singleuser","true"DBCCCHECKDB("db_name",REPAIR_ALLOW_DATA_LOSS)GO如果在执行DBCCCHECKDB("db_name",REPAIR_ALLOW_DATA_LOSS)命令时提示说数据库未处于单用户模式状态的话,则重新启动SQLServer服务,然后继续尝试。
9. 如果DBCCCHECKDB("db_name",REPAIR_ALLOW_DATA_LOSS)命令失败,请转至第10步,否则若成功修复了数据库中的错误:重新执行DBCC CHECKDB("db_name")命令,确认数据库中已没有错误存在。
SQLSERVER2008数据库可疑的解决步骤

SQLSERVER2008数据库可疑的解决步骤第一篇:SQLSERVER2008 数据库可疑的解决步骤把问题数据库备份后直接删除停掉SQLSERVER服务,把服务器上出问题的数据库, 假设名称为ErrorDB的数据库文件及日志文件备份到其他目录,然后直接将其删除,把其数据库文件及日志文件也删除 2 新建同名数据库启动SQLSERVER服务,新建同名数据库ErrorDB,文件目录和日志和原来一致 3 用备份的数据库文件替换新的数据库文件停掉SQLSERVER服务,把备份的数据库文件替换新的数据库文件(只替换数据库文件,不替换日志文件)启动SQLSERVER服务,打开数据库,这时数据库应该是不能访问的-------------------设置应急模式、单用户模式、检查修复数据,取消单用户模式----------------------4 将数据库设置为应急状态alter database ErrorDB set emergency 执行后,为了保险起见,重新停止、开启的SQLSERVER服务再打开数据库,已经可以看到里面的内容了,如表,视图,存储过程等数据库名称后有紧急标志,能看到数据库结构,但无法进行备份等操作 5 将数据库设置为单用户模式ALTER DATABASE ErrorDB SET SINGLE_USER 6 对数据库进行检查修复dbcc checkdb(EIMSDb,REPAIR_ALLOW_DATA_LOSS)dbcc checkdb(EIMSDb,REPAIR_REBUILD)操作后,仍然停止启动SQLSERVER服务(不确定是否需要,我只是为了想无干扰查看执行后的数据库状况)重新打开数据库,已经是正常状态了,没有应急提示了7 取消单用户模式exec sp_dboption EIMSDb, N'single', N'false'至此,数据库恢复完毕,对数据库进行BAK第二篇:数据库可疑SQLSERVER2008 数据库可疑的解决步骤2012年8月28日下午公司内部ERP系统突然访问提示超时,经检查发现是数据库可疑造成.停掉SQLSERVER服务,停掉网站把出问题的数据库文件及日志拷贝到其他目录进行备份.尝试脱机,或分离等,均无效果.在其他机器尝试还原问题数据库,提示日志文件被破坏.在网上搜索其他帮助并求助朋友后,恢复成功,操作如下:-------------------------备份并新建同名数据库,并替换原数据文件-----------------------------1 把问题数据库备份后直接删除停掉SQLSERVER服务,把服务器上出问题的数据库, 假设名称为ErrorDB的数据库文件及日志文件备份到其他目录,然后直接将其删除,把其数据库文件及日志文件也删除新建同名数据库启动SQLSERVER服务,新建同名数据库ErrorDB,文件目录和日志和原来一致用备份的数据库文件替换新的数据库文件停掉SQLSERVER服务,把备份的数据库文件替换新的数据库文件(只替换数据库文件,不替换日志文件)启动SQLSERVER服务,打开数据库,这时数据库应该是不能访问的-------------------设置应急模式、单用户模式、检查修复数据,取消单用户模式----------------------4 将数据库设置为应急状态 alter database 数据库实体名set emergency 执行后,为了保险起见,重新停止、开启的SQLSERVER服务再打开数据库,已经可以看到里面的内容了,如表,视图,存储过程等数据库名称后有紧急标志,能看到数据库结构,但无法进行备份等操作将数据库设置为单用户模式ALTER DATABASE数据库实体名SET SINGLE_USER 6 对数据库进行检查修复dbcc checkdb(数据库实体名,REPAIR_ALLOW_DATA_LOSS)dbcc checkdb(数据库实体名,REPAIR_REBUILD)操作后,仍然停止启动SQLSERVER服务(不确定是否需要,我只是为了想无干扰查看执行后的数据库状况)重新打开数据库,已经是正常状态了,没有应急提示了取消单用户模式exec sp_dboption 数据库实体名, N'single', N'false' 至此,数据库恢复完毕,对数据库进行BAK 重启网站,访问正常。
常规SQL SERVER数据库置疑后恢复步骤

常规SQL SERVER数据库置疑后恢复步骤--1.恢复步骤:--a.将smlog_log.ldf文件备份到其它目录下;--b.将源目录下的smlog_log.ldf文件改名为smlog_log_bak.ldf;--c.执行以下语句修改数据库的状态:use Mastergoupdate sysdatabases set status=32768 where name='数据库名称' --修改状态,設為緊急狀態goshutdown with nowait --停止数据库服务器go--d.退出SQL并在(COMMAND)命令行模式中通过下面的代码重新启动SQL:sqlservr -c -T3608 -T4022 --安全模式启动SQL SERVER--e.在查询分析器中执行以下语句来查看刚刚修改过状态的数据库状态:select Name,Status from sysdatabases where Name='数据库名稱'--f.执行以下代码新建日志文件:dbcc traceon(3604)--跟踪dbcc rebuild_log('数据库名称','日志文件全路徑') --文件名要有全路径和扩展名--dbcc rebuild_log('prs_msc','d:\mscsql\mssql\data\prs_msc_log.ldf --g.将数据库置回正常状态:update sysdatabases set status=0 where name='数据库名称'--h.重新启动数据库后执行以下语句检查数据库:DBCC CHECKDB --如果执行完有错误用以下语句修复--i.要修复数据库必需将数据库改为单用户模式:Exce sp_dboption '数据库名称','single user','true'---('false'恢复多用户)--j.执行以下语句修复数据库:DBCC CHECKDB('数据库名称',REPAIR_ALLOW_DATA_LOSS) REPAIR_ALLOW_DATA_LOSS:是比较高级的修复方式REPAIR_FAST:是简单快速的修复方式/*處理状态就为"置疑"的數據庫备份数据文件,然后按下面的步骤处理:1.新建一个同名的数据库(数据文件与原来的要一致)2.再停掉sql server(注意不要分离数据库)3.用原数据库的数据文件覆盖掉这个新建的数据库4.再重启sql server5.此时打开企业管理器时会出现置疑,先不管,执行下面的语句(注意修改其中的数据库名)6.完成后一般就可以访问数据库中的数据了,这时,数据库本身一般还要问题,解决办法是,利用数据库的脚本创建一个新的数据库,并将数据导进去就行了.*/USE MASTERGOSP_CONFIGURE 'ALLOW UPDATES',1GORECONFIGURE 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',0GOreconfigure with overrideGosp_dboption '置疑的数据库名', 'single user','false'Go关于SQL数据库置疑的修复方法发布日期:2008/11/17 18:10:22 来源:作者:点击:1078斑竹广告联盟问题现象:数据库后面有“置疑”字样,查看系统事务日记出现以下错误:错误1---------------------------------------------错误: 823,严重度: 24,状态: 2I/O error 23(数据错误(循环冗余检查)。
SQL数据库置疑的解决办法

SQL数据库置疑的解决办法数据库管理 2008-11-14 14:24:58 阅读435 评论2字号:大中小以下为恢复方法:-------------------------------------------------------------------------------步骤1:创建一个新的数据库,命名为原来数据库的名字。
步骤2:停止SQL Server步骤3:把老数据库的MDF文件替换新数据库的相应的MDF文件,并把LDF文件删除。
步骤4:重新启动SQL Server服务,然后运行如下命令:Use MasteGosp_configure 'allow updates', 1reconfigure with overrideGobegin tranupdate sysdatabases set status = 32768where name = 'db_name'--Verify one row is updated before committin gcommit tran步骤5:停止SQL然后重新启动SQL Server服务,然后运行如下命令:DBCC TRACEON(3604)DBCC REBUILD_LOG('db_name','c:\mssql7\data\dbxxx_3.ldf')Go步骤6:停止SQL然后重新启动SQL Server服务,然后运行:use masterupdate sysdatabases set status = 8 wh ere name = 'db_name'Gosp_configue 'allow updates', 0reconfigure with overridego步骤7:运行dbcc checkdb(db_name) 检查数据库的完整性恢复数据库后,即使貌似恢复了,说不定中间也会有错误,最合理的解决办法是,利用当前恢复的数据库的脚本创建一个新的数据库,并将数据导进去,然后使用新的数据库替代恢复的数据库。
解决SQLSERVER2008系统数据库MSDB“可疑”的方法

解决SQL Server2008 msdb可疑的数据库的方法请参考文章ProblemDue to a recent rebuild of the master DATAbase for a SQL Server instance, I now need to RESTore the msdb and model databases. In this tip we walk through the process that you need to follow to restore the model and msdb databases successfully.SolutionBefore we get started, let's quickly discuss what the msdb and model databases are used for.● The msdb database contains scheduled jobs, alerts and backup history therefore a proper backup plan should be implemented for the msdb system database.● The model database is the blue print for creating any new user database for that particular instance of SQL Server. DBAs can modify the model database with whatever settings that are required and when a new user database is created it will reflect the configuration of the model database. If the model database has been modified then it should be backed up.Hence both the msdb and model DATAbases may need to be recovered in scenarios like DATAbase corruption, a rebuild of the master database or after a new server configuration. The RESTore process of msdb or model demands additional considerations than that of a user databases. The RESTore process may get complicated if versions are not tracked andexclusive access is not ensured in all aspects. In the next sections we will go through the restore process for the msdb and model databases.Note: this exercise was performed on SQL Server 2005, but the same rules would also be applied on SQL Server 2005 and onwards.Backup msdbUse the following command to create a full backup of the msdb database using T-SQL commands. You will need to modify the script to use a valid backup path. You can perform the same process for the model database as well.--Script 1: Create backup of msdbUSE [master]GOBACKUP DATABASE [msdb]TO DISK = N'E:\MSDB_Backup.Bak'WITH INIT,NAME = N'msdb Backup for MSSQLTips Demo'GOAfter this is complete we have a full backup that can be RESTored.Prepare for RESToreTo ensure we have a smooth restore we need to follow these steps.● Get the version of destination server● Get the version of source server on which the backup was created● Match the versions for the source and destination servers● Ensure exclusive access to the DATAbaseThe term source server here refers to the server on which the backup was created and destination server is where the restore will occur.Get version of destination serverThe versions of SQL Server need to be the same for the source and destination when restoring the msdb or model database. If the versions for the source and destination servers do not match then the restorewill fail as shown below:Msg 3168, Level 16, State 1, Line 1The backup of the system DATAbase on the device E:\MSDB_Backup.Bak cannot be RESTored because it was created by a different version of the server (9.00.1399) than this server (9.00.5000).Msg 3013, Level 16, State 1, Line 1RESTORE DATABASE is terminating abnormally.In the case of a mismatch, the version of SQL Server for the destination needs to be manipulated by installing or removing service packs.Here are the three ways to get the version for the SQL Server database engine.Using SSMS Object ExplorerConnect to a SQL Server instance through SSMS and find the SQL Server version in object explorer as shown below.Using SERVERPROPERTY system functionThe SERVERPROPERTY system function can be used for retrieving SQL Server version information to get edition and service pack information.Using @@VersionThe SQL Server version can also be retrieved by using @@Version. It can be used in a simple select statement as shown below.Get version of source server on which backup was createdNow we need to get the version of the source server on which the backup was created. The best way to do this is to get the information from the backup file itself as shown below using the RESTORE HEADERONLY command.-- Script 2: Get information of backup fileRESTORE HEADERONLYFROM DISK = N'E:\MSDB_Backup.Bak'GOAbove is the partial output from the command and we can see the SoftwareVersionMajor, SoftwareVersionMinor andSoftwareVersionBuild. These three values equate to the output from the other commands we look at earlier.Match the versions of source and destination serverIn our case we have version 9.0.5000 which matches both the source and destination servers. If this is not the case then apply or remove service packs on the destination server to match the source server. Once both versions are the same then we are ready to go further with the process.Following is a mapping of version codes for SQL Server 2005 and onwards from Microsoft SQL Server support.Ensure exclusive accessExclusive access for the DATAbase is required just like RESToring any database, but for the msdb it is slightly more demanding. In the case of msdb we also have to consider the SQL Agent service. If the SQL Server agent service is running then exclusive access can not be achieved. Below we can see that the SQL Agent service is running by querying sys.sysprocesses.So for msdb we need to stop the SQL Agent service to make sure we can get exclusive access. This can be done by right clicking on SQL Server Agent and selecting Stop.RESTore msdbAt this point our requirements are fulfilled and we are ready to perform the restore. Execute the following command for the restore process.--Script 3: Restore msdbUSE masterGORESTORE DATABASE [msdb]FROM DISK = N'E:\MSDB_Backup.Bak'WITH REPLACEGOThe msdb database is now restored as shown below. Now we need to put the database back in multi user (if this was changed) and start the SQL Server agent service.The same requirements and process also work for the model database except that the SQL Agent service is not an issue.Another thing to note is that you can restore msdb and model databases across editions such as Express, Developer, Standard and Enterprise. You only need to be concerned that the versions are the same.Next Steps● As part of best practices, go through your various phases of a disaster recovery process. Manipulating system DATAbases is an integral part of disaster recovery.● Click here to read a tip about getting exclusive access of SQL Server databases● Click here to read a tip about system databases in SQL Server● Click here to read details about versions and releases of SQL Server● Click here to read about using SERVERPROPERTY● Click here to read about using @@Version。
SQL数据库置疑解决方案(原因、预防、修复)附图

SQL数据库置疑解决方案一、数据库置疑产生的原因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是数据库日志文件。
例子:假设数据库为pdm,其数据文件为pdm_data.mdf,日志文件为pdm_log.ldf。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
SQL Server 2008数据库被标记为可疑的解决方法
2011-08-23 16:36 佚名火魔网字号:T | T
本文我们主要介绍了SQL Server 2008数据库被标记为可疑时的解决方法,希望能够对您有所帮助。
AD:
在使用SQL Server 2008数据库时发现数据库被标记为可疑,查看网上的资料终于找到了解决办法,接下来我们就来介绍解决方法。
解决方法:
当数据库发生这种操作故障时,可以按如下操作步骤可解决此方法,打开数据库里的Sql 查询编辑器窗口,运行以下的命令。
1、修改数据库为紧急模式
ALTER DATABASE Zhangxing SET EMERGENCY
2、使数据库变为单用户模式
ALTER DATABASE Zhangxing SET SINGLE_USER
3、修复数据库日志重新生成,此命令检查的分配,结构,逻辑完整性和所有数据库中的对象错误。
当您指定“REPAIR_ALLOW_DATA_LOSS”作为DBCC CHECKDB命令参数,该程序将检查和修复报告的错误。
但是,这些修复可能会导致一些数据丢失。
DBCC CheckDB (Zhangxing, REPAIR_ALLOW_DATA_LOSS)
4、使数据库变回为多用户模式
ALTER DATABASE Zhangxing SET MULTI_USER
也可以这样做:
1:重新建立一个,一样的数据库,路径名称,文件都一样。
2:关掉SQL Server服务;
3:把源文件COPY过来;
4:开启SQL Server服务,这样问题同样就解决了。
以上就是SQL Server 2008数据库被标记为可疑的两种解决方法,本文就介绍到这里了,希望本次的介绍能够对您有所收获!
今天在客户服务器的数据库里面的一个数据库突然出现了点问题,数据库状态变为可疑了,这个问题之前有见过,虽然解决了,但并没有把过程和解决方法记录下来,决定这次记录在博客园里,方便自己也方便他人在遇到这个问题的时候,能快速解决!废话不多说,先说说数据库变可疑的原因:
在进行些不正常操作如数据库在读写时而无故停止数据库,从而导致Sql Serv er 数据库不正常中断,当再次打开数据库时会发现某些数据库会被标记为“可疑”(suspect),即在数据库名旁加上了黄色的惊叹号,这时数据库就不能再被打开了,但数据库的结构及数据内容都还是存在的。
当数据库发生这种操作故障时,可以按如下操作步骤可解决此方法,打开数据库里的Sql 查询编辑器窗口,运行以下的命令(注意:jd13dafa为对应可疑的数据库名称,执行时,请改为你的可疑的数据库名称)。
1、修改数据库为紧急模式
ALTER DATABASE jd13dafa SET EMERGENCY
2、使数据库变为单用户模式
ALTER DATABASE jd13dafa SET SINGLE_USER
3、修复数据库日志重新生成,此命令检查的分配,结构,逻辑完整性和所有数据库中的对象错误。
当您指定“REPAIR_ALLOW_DATA_LOSS”作为DBCC CHECKDB命令参数,该程序将检查和修复报告的错误。
但是,这些修复可能会导致一些数据丢失。
DBCC CheckDB (jd13dafa , REPAIR_ALLOW_DATA_LOSS)
4、使数据库变回为多用户模式
ALTER DATABASE jd13dafa SET MULTI_USER
5、开始->运行->输入cmd->打开DOS命令窗口,输入以下命令重启数据库服务(此处可以直接到服务列表里,重新启动数据库服务,为了方便我直接用DOS命令了)
Net stop mssqlserver --停止服务
Net start mssqlserver --启动服务
重新打开Sql Server,查看被标记为“可疑”的数据库已恢复正常状态。
(注意执行命令过程中可能会报一些错误,请无视,按照步骤执行完毕就行了,有问题,大家多少交流836911886,加我请记得说:博客园)。