//Record Lock in SQL
select cmd,* from sys.sysprocesses
where blocked > 0
exec sp_lock
exec sp_who
exec sp_who2
select
object_name(resource_associated_entity_id) as 'TableName' ,*
from
sys.dm_tran_locks
where resource_type = 'OBJECT'
and resource_database_id = DB_ID()
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
http://shahnawazdba06.blogspot.com/2016/05/find-table-which-has-row-lock.html
select cmd,* from sys.sysprocesses
where blocked > 0
exec sp_lock
exec sp_who
exec sp_who2
select
object_name(resource_associated_entity_id) as 'TableName' ,*
from
sys.dm_tran_locks
where resource_type = 'OBJECT'
and resource_database_id = DB_ID()
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
http://shahnawazdba06.blogspot.com/2016/05/find-table-which-has-row-lock.html
No comments:
Post a Comment