Thursday, December 1, 2011

Msg 1807, Level 16, State 3, Line 1 Could not obtain exclusive lock on database ‘model’. Retry the operation later. Msg 1802, Level 16, State 4, Line 1 CREATE DATABASE failed. Some file names listed could not be created. Check related errors.

Problem:

Msg 1807, Level 16, State 3, Line 1
Could not obtain exclusive lock on database ‘model’. Retry the operation later.
Msg 1802, Level 16, State 4, Line 1
CREATE DATABASE failed. Some file names listed could not be created. Check related errors.


Solution:

Option 1:
            Disconnect and Reconnect your SQL Server Management Studio’s session. Your error will go away.
Option 2:
Root Cause: Root cause of this error may be one of the following reason
1. Somebody exclusively open the Model database in different session
2. If more than one create database statements attempt to run simultaneously
How to identity:
Use master 
GO
IF EXISTS(SELECT request_session_id  FROM sys.dm_tran_locks
WHERE resource_database_id = DB_ID('Model'))
 PRINT 'Model Database being used by some other session'
ELSE
 PRINT 'Model Database not used by other session'
 
          So we can identify that whether the Model database being execlusively used by any session.., If you found anybody using the Model database execlusively, You can identify what kind of statement being used by the session...using the script given below

SELECT request_session_id  FROM sys.dm_tran_locks
WHERE resource_database_id = DB_ID('Model')
         The script will return the session ID (i.e: 53)
         We have to identity what kind of query/activity being performed by this session(53).

DBCC InputBuffer(53) 
 
    EventInfo column returns the query performed, Based on that, you have to decide whether the Session ID(53) can be Aborted/ Not. If you want to abort the session(53),
run the command 
    Kill 53 
    Now you can try to create a new Database..!  

1 comment:

  1. Someone essentially help to make critically articles I'd state.
    This is the first time I frequented your web page and so
    far? I amazed with the research you made to create this particular post extraordinary.

    Fantastic process!

    Feel free to surf to my site ... domain

    ReplyDelete