title: How to debug a T-SQL trigger?
body: <p>I have a table t, which has an "after insert" trigger called trgInsAfter. Exactly how do i debug it? i'm no expert on this, so the question and steps performed might look silly.</p>
  
  <p>The steps i performed so far are:
   1. connect to the <code>server instance</code> via <code>SSMS</code> (using a Windows Admin account)</p>
  
  <ol>
  <li><p>right click the trigger node from the lefthand tree in SSMS and double click to open it, the code of the trigger is opened in a new query window (call this Window-1) as :  blah...., </p>
  
  <pre><code>ALTER TRIGGER trgInsAfter AS .... BEGIN ... END
  </code></pre></li>
  <li><p>open another query window (call this Window-2), enter the sql to insert a row into table t:</p>
  
  <pre><code>insert t(c1,c2) values(1,'aaa')
  </code></pre></li>
  <li><p>set a break point in Window-1 (in the trigger's code)</p></li>
  <li><p>set a break point in Window-2 (the insert SQL code)</p></li>
  <li><p>click the Debug button on the toolbar while Window-2 is the current window</p>
  
  <p>the insert SQL code's breakpoint is hit, but when I look at Window-1, the break point in the trigger's code has a tooltip saying <code>'unable to bind SQL breakpoint, object containing the breakpoint not loaded'</code></p></li>
  </ol>
  
  <p>I can sort of understand issue: how can <code>SSMS</code> know that the code in Window-1 is the trigger </p>
  
  <p>I want to debug? i can't see where to tell SSMS that 'hey, the code in this query editor is table t's inssert trigger's code'</p>
  
  <p>Any suggestions?</p>
  
  <p>Thanks</p>