Wednesday, March 20, 2013

Fix : Could not obtain exclusive lock on database 'model'

Could not obtain exclusive lock on database 'model'

MS-SQL Database Error
---------------------------
Create failed for Database 'DbName1'. An exception occurred while executing a Transact-SQL statement or batch.Could not obtain exclusive lock on database 'model'. Retry the operation later.CREATE DATABASE failed. Some file names listed could not be created. Check related errors.


As Model database is a template for new databases hence SQL Server will place a Exclusive lock on Model database while creating any new databases. So we need to make sure there wont be any active connections to Model database.

Solution:
Use the below query to identify who connected to model database,

SELECT spid, loginame, DB_NAME(dbid) FROM master..sysprocesses WHERE DB_NAME(dbid)='Model'

Disconnect all sessions from Model Database and try creating new database.

 

1 comment:

  1. Hello Kalyan garu

    Good One..

    Thanks for posting..

    Regards
    Swathi Vineela

    ReplyDelete