Showing posts with label model. Show all posts
Showing posts with label model. Show all posts

Friday, May 1, 2015

Find database lock



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'


---to see what is locking up the database
SELECT request_session_id FROM sys.dm_tran_locks

WHERE resource_database_id = DB_ID('Model')

Friday, February 7, 2014

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

SELECT spid, loginame, DB_NAME(dbid) FROM master..sysprocesses WHERE DB_NAME(dbid)='Model' If you get the following errors - 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. kill the connections