SQL Query to Release lock on database

On October 07

SQL Query to Release lock on database

 

1. First find out the Lockin ID with the following query:

SELECT
     blocking_session_id AS BlockingSessionID,
     session_id AS VictimSessionID,

     (SELECT [text] FROM sys.sysprocesses
      CROSS APPLY sys.dm_exec_sql_text([sql_handle])
      WHERE spid = blocking_session_id) AS BlockingQuery,

     [text] AS VictimQuery,
     wait_time/1000 AS WaitDurationSecond,
     wait_type AS WaitType,
     percent_complete AS BlockingQueryCompletePercent
FROM sys.dm_exec_requests
CROSS APPLY sys.dm_exec_sql_text([sql_handle])
WHERE blocking_session_id > 0

 

2. Then kill the Locking id with the following query :

     KILL 63

 

Sql Query To release lock on database



Responses

Nice

Yes, really goodone.

Could have been better.

Cool.

?

Leave your comment