title: When it's necessary to check @@trancount > 0 in try catch block?
body: <p>Sometimes I saw the following code snippet. When is the <code>if @@trancount &gt; 0</code> necessary with <code>begin try</code>? Both of them? Or it's a safe way(best practice) to check it always in case it's rollback before the check?</p>
  
  <pre><code>begin tran
  begin try
    ... just several lines of sql ...
    if @@trancount &gt; 0 commit tran
  end try
  begin catch
    if @@trancount &gt; 0 rollback tran
  end catch
  </code></pre>