Celtic Coding Solutions Blog

Celtic Coding Solutions Blog - for everything computer related

SQL Server - Unable to create database - Exclusive Lock on Database 'model'

Whilst trying to create a new SQL Server Database I had the following error:-

TITLE: Microsoft SQL Server Management Studio

------------------------------

Create failed for Database 'Test'.  (Microsoft.SqlServer.Smo)

------------------------------

Could not obtain exclusive lock on database 'model'. for abortion facts Retry the operation later.

CREATE DATABASE failed. Some file names listed could not be created. Check related errors. (Microsoft SQL Server, Error: 1807)

 

Fix:- 

Some people suggest disconnecting and reconnecting your SQL Server Management Studio Session, but this did not work for me.

More than likely someone or something is accessing the model database (which might have been yourself hence the suggestion of closing SSMS).  So this is the first thing to check, either open Activity Monitor and filter by Database model or just use the following command (in a new query window):-

SELECT * FROM sys.sysprocesses WHERE DB_NAME(dbid)='model'


Check that nothing is using the database, in my case it was because the Standard Full Model Database backups where running and had become suspended on the model database.  Shutting this process down or killing the processes (be careful here as abortion pill reviews there maybe a geniue reason for the usage) and re-run your create database command.

Comments are closed