Sunday 18 November 2007

Suspect Database

Do you ever get this kind of problem ?
When you run an apllication then this kind of message will appear :
"96/11/18 10:48:32.60 kernel udopen: Operating System Error 32 (The
process cannot access the file because it is being used by another
process.) during the creation/opening of physical device,
C:\DATA\SQL\MSDB.DAT (or C:\DATA\SQL\MSDB.MDF)

96/11/18 10:48:32.60 kernel udactivate (primary): failed to open
device C:\MSSQL\DATA\MSDB.DAT (or C:\DATA\SQL\MSDB.MDF) for vdn 127"
or
"96/11/18 10:48:32.60 kernel udopen: operating system error 2(The
system cannot find the file specified.) during the creation/opening
of physical device C:\MSSQL\DATA\MSDB.DAT (or C:\DATA\SQL\MSDB.MDF)

96/11/18 10:48:32.60 kernel udactivate (primary): failed to open device C:\MSSQL\DATA\MSDB.DAT (or C:\DATA\SQL\MSDB.MDF) for vdn 127"

According to microsoft support it happen because the sql server device is being used by another process  
such as back up database or the file is missing.
You can fix this problem with this following step :
  1. Ensure that the device file is actually available.
  2. 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.
  3. 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!
  4. Stop and restart SQL Server.
  5. Verify that the database was recovered and is available.
  6. Run DBCC NEWALLOC, DBCC TEXTALL, and DBCC CHECKDB.
More information visit http://support.microsoft.com/kb/180500