MS SQL 1807 Error – Solved

While trying to create a new database in MS SQL , I kept getting a 1807 error, complaining that MS SQL can’t obtain exclusive lock on database ‘model’

Create failed for Database ‘x’. (Microsoft.SqlServer.Smo)

ADDITIONAL INFORMATION:

An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)

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. (Microsoft SQL Server, Error: 1807)

 

To solve this:

  • run sp_who2 query
  • find out which process holds a lock on ‘model’ database
  • kill that process using :

KILL $SPID
GO

Notes regarding killing processes:

  • Be careful killing the following types of processes AWAITING COMMAND, CHECKPOINT SLEEP, LAZY WRITER, LOCK MONITOR, SIGNAL HANDLER, it’s probably a bad idea killing them forcefully
  • Instead of killing processes it sometimes helps to restart the following services / applications
    • SQL Management Studio
    • Appassure Agent service
    • SQL Server VSS Writer service

Leave a Reply

Your email address will not be published. Required fields are marked *