Article ID: 180500
Article Last Modified on 5/30/2006
APPLIES TO
- Microsoft SQL Server 6.0 Standard Edition
- Microsoft SQL Server 6.5 Standard Edition
This article was previously published under Q180500
SYMPTOMS
SQL Server marks a database suspect if any of the device files for the database are unavailable when it attempts to start. You may see either of the following sets of messages in the SQL Server error log:
Error message 1
Error message 2
These will be followed later in the log by:
For example, performing the following steps will demonstrate the problem:
- Stop SQL Server.
- Issue the following command from a command prompt at the Mssql\Data directory:
ren msdb.dat msdb.sav
- Start SQL Server.
You will see the above errors (the ones from the second set) in the SQL Server errorlog. If you then issue the following query in the master database
select name, dbid, mode, status from sysdatabases where dbid = db_id('msdb')
You receive the following results:
name dbid mode status ------------------------------ msdb 5 0 328
The status of 328 evaluates to:
truncate log on chkpt database not recovered yet database is suspect
For more information, see the "Sysdatabases (Master Database Only)" topic in the SQL Server Books Online.
CAUSE
At startup, SQL Server attempts to obtain an exclusive lock on the device file. If the device is being used by another process (for example, backup software) or if the file is missing, the scenario described above will be encountered. In these cases, there is usually nothing wrong with the devices and database. For the database to recover correctly, the device must be made available, and the database status must be reset.
WORKAROUND
To work around this problem, perform the steps below. Note that the final step is critical.
- Ensure that the device file is actually available.
- Use the supplemental stored procedure sp_resetstatus to reset the status of a suspect database. If you have not already done so, create this procedure by executing the Instsupl.sql script, found in the Mssql\Install directory. For more information on sp_resetstatus, see the "Resetting the Suspect Status" topic in the SQL Server Books Online.
Execute sp_resetstatus in the master database for the suspect database:
use master go exec sp_resetstatus msdb -- replace msdb with your database name
You will see the following output:
Prior to Update sysdatabases attempt for DBName='msdb', the mode=0 and status=328 (status suspect_bit=256). For DBName='msdb' in sysdatabases, status bit 256 was forced Off and mode was forced to 0. WARNING: You MUST stop/restart SQL Server prior to accessing this database!
- Stop and restart SQL Server.
- Verify that the database was recovered and is available.
- Run DBCC NEWALLOC, DBCC TEXTALL, and DBCC CHECKDB.
MORE INFORMATION
If the database is still marked as suspect after performing these steps, there may be other problems preventing the database from recovering. At this point, you can either restore from a good backup or set the database to emergency mode and use the bulk copy program (BCP) to bulk copy the data out. For more information, click the following article number to view the article in the Microsoft Knowledge Base:
165918 Bypass (Emergency) mode and DUMP TRANSACTION WITH NO_LOG
Important If you use this article (Q165918) and are unsure of the full consequences of any of the actions you are performing, contact your primary support provider for assistance.
Additional query words: db checkpoint
Keywords: kbprb KB180500