title: How to figure out what object is represented by associatedObjectId during blocking?
body: <p>I got report from another team about blocking in SQL Server. Looking at results of </p>
  
  <pre><code>  Exec sp_who2
  </code></pre>
  
  <p>and query from blog by Glenn Berry</p>
  
  <pre><code>SELECT blocking.session_id AS blocking_session_id
         ,blocked.session_id AS blocked_session_id
         ,waitstats.wait_type AS blocking_resource
         ,waitstats.wait_duration_ms
         ,waitstats.resource_description
         ,blocked_cache.text AS blocked_text
         ,blocking_cache.text AS blocking_text
      FROM sys.dm_exec_connections AS blocking
      INNER JOIN sys.dm_exec_requests blocked
          ON blocking.session_id = blocked.blocking_session_id
      CROSS APPLY sys.dm_exec_sql_text(blocked.sql_handle) blocked_cache
      CROSS APPLY sys.dm_exec_sql_text(blocking.most_recent_sql_handle) blocking_cache
      INNER JOIN sys.dm_os_waiting_tasks waitstats
          ON waitstats.session_id = blocked.session_id
  </code></pre>
  
  <p>I want not able to catch anything being blocked. Running this multiple time I start to notice that something shows up but next time I run query, blcoking is gone. </p>
  
  <p>I created temp table by <code>SELECT INTO</code></p>
  
  <pre><code>       ,blocking_cache.text AS blocking_text
      INTO #TempBlockingTable
      FROM sys.dm_exec_connections AS blocking
  </code></pre>
  
  <p>After that modified query to be <code>INSERT INTO SELECT</code>. Now I was able to run query as many times as I want without fearing that results would be gone. </p>
  
  <p>I kept running query for about 10 seconds until I finally got some results.</p>
  
  <pre><code> SELECT * FROM #TempBlockingTable
  </code></pre>
  
  <p>Looking at <code>resource_description</code> column from <code>sys.dm_os_waiting_tasks</code> I found that data is displayed in the following format.</p>
  
  <pre><code> &lt;type-specific-description&gt; id=lock&lt;lock-hex-address&gt; mode=&lt;mode&gt; associatedObjectId=&lt;associated-obj-id&gt; 
  </code></pre>
  
  <p>Microsoft documentation on <code>sys.dm_os_waiting_tasks</code> <a href="http://technet.microsoft.com/en-us/library/ms188743.aspx" rel="nofollow">http://technet.microsoft.com/en-us/library/ms188743.aspx</a> does not have definition for <code>associatedObjectId</code></p>