Microsoft KB Archive/199216

= BUG: Cannot Restore Database When Model Database Is in Use =

Article ID: 199216

Article Last Modified on 10/15/2002

-

APPLIES TO


 * Microsoft SQL Server 7.0 Standard Edition

-



This article was previously published under Q199216



BUG #: 49934 (SQLBUG_70)



SYMPTOMS
Restoring a database while another process is using the model database may cause the restore to fail, with the following error message:

SQL-DMO Error: Could not obtain exclusive lock on database Model

In other words, if the connection doing a RESTORE DATABASE statement cannot get an exclusive lock on the model database, the restore may fail.



CAUSE
Due to the way the the RESTORE statement works in SQL Server 7.0, the SQL Server must have an exclusive lock on the model database to assign a new dbid to the database being restored. Therefore, if there is another connection using the model database at the time of the restore, the exclusive lock is denied, so the restore fails.



WORKAROUND
To work around this problem, use the sp_who stored procedure to determine whether there are any processes holding locks in the model database before doing a restore. If so, wait until the process finishes before attempting the restore.



STATUS
Microsoft has confirmed this to be a problem in SQL Server version 7.0.

Additional query words: db restoration fails

Keywords: kbbug kbpending KB199216

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.