title: SQL Server: Show Plan for Locks
body: <p>I'm new to SQL SErver and wonderingif there anyway to :</p>
  
  <pre><code>set showplan_all on;
  </code></pre>
  
  <p>... and then run a multi-table query and have it show me the locks that are going to be held on each database object?</p>
  
  <p>I'm particularly interested in finding the lock order so that I might be able to decrease the likelihood of a deadlock.</p>
  
  <p>I know that sp_lock() can be used to show current locks but to use this I would have to open a transaction with a lockhold hint.</p>
  
  <p>Is there a simpler way?</p>