This blog is created to add all the information and experiences that I have learnt while working on MS sql server as a DBA. The blog is also updated frequently with the real world problem that I encounter hands on at work and the resolutions to resolve them. I hope this blog will be of some use to you and you will revisit. Thank you for stopping by and you are welcome to leave comments.
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')
Labels:
Administration,
create database,
data,
database lock,
locks,
model,
transaction lock
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment