title: mssql how to get lock on whole table without select statement?
body: <p>MSSQL 2005 .I want to get a lock on a table at the start of transaction and only release it at the end of the transaction</p>
  
  <pre><code>BEGIN TRANSACTION;
  -- get lock
  BEGIN TRY
  END TRY
  BEGIN CATCH
      IF @@TRANCOUNT &gt; 0 BEGIN
          ROLLBACK TRANSACTION; 
          -- release lock
      END
  END CATCH;
  
  IF @@TRANCOUNT &gt; 0 BEGIN
      COMMIT TRANSACTION;
      -- release lock
  END
  GO 
  </code></pre>
  
  <p>Does lock on table gets automatically released once transaction has completed or rolledback?</p>