Quantcast
Channel: shopSharepoint.com: Blog
Viewing all articles
Browse latest Browse all 80

SQL 2008 : Could not obtain exclusive lock on database ‘Model’

$
0
0

When a new database is created, SQL server takes it’s properties from the “model” database which acts as a template for any new user database.  SQL Server attempts to obtain an EXCLUSIVE lock on the model database during this process.  This is to prevent other processes from updating the model database’s schema whilst the new database is being created, so that the new database’s schema is in a known, consistent state.

If you are getting this below error :

pic

There are three reasons why you can get this error:

1)  Look out for anyone using 'Model'. Even if they open up a window and select model database from the drop down. ask them to close those connections by closing those windows.

2)  It can also occur if the “AUTOCLOSE” property is set to ON for the “model” database as a result of which when a new user database is being created, if the model database is closed at that time (when this property is on, the database is shutdown cleanly when it is not in use), you can get this error because the new database takes it’s default properties from the model database and it is close at that time as a result of a log-off from some other session.

NOTE:  AutoClose should always be OFF for all databases.  Setting this to ON is strictly against the recommendations.

If it is occuring because of this reason, correct the setting and re-start the service.

3)  Another reason is that if you have previously opened the model database in Enterprise Manager/Management Studio (SQL 2005), then closed it, the connection to the database remains open, which means that the Create Database command cannot acquire the exclusive access lock that it requires to execute successfully.  For the AutoClose:


SET NOCOUNT ON

GO

SELECT DATABASEPROPERTYEX('model' , 'IsAutoClose' ) AS [AutoClose]

GO

ALTER DATABASE [model] SET AUTO_CLOSE OFF

GO


Viewing all articles
Browse latest Browse all 80

Trending Articles