I found this from http://sqlserverdb.blogspot.com/2011/06/find-all-system-and-user-defined-error.html:
SELECT
t.resource_type,
t.resource_database_id,
t.resource_associated_entity_id,
t.request_mode,
t.request_session_id,
w.blocking_session_id
FROM sys.dm_tran_locks as t
INNER JOIN sys.dm_os_waiting_tasks AS w
ON t.lock_owner_address =w.resource_address
And from there I am trying to derive the actual SQL statement that is coming from w.blocking_session_id but I can't seem to find the right bits. Can anyone point me to a clue?
I use this in one SSMS (SQL2008) query window:
begin transaction
update MyTable with (tablockx)
set MyTableColumn = MyTableColumn
where 1 = 0
And in another new window I executed this:
select * from MyTable
And SSMS shows it waiting 'forever' to perform the query, so it is the block victim. But I want to find out who the problem code actually is.
Thanks.