title: how to force a lock to be obtained in SQL Server?
body: <p>I am working on making an application run on both Postgres and SQL Server.</p>
  
  <p>in PostgreSQL you can do something like</p>
  
  <pre><code>lock mytable exclusive;
  </code></pre>
  
  <p>which would keep the entire table from being written to(insert/updated). I need the entire table to be locked while certain things are updated(and RIDs can not be changed or else it'll screw it up)</p>
  
  <p>I am not seeing any simple way to force Sql Server to do this though. The only things I'm seeing are for one query and are only "hints" which may or may not be followed. How can I lock a table so that it is read-only in SQL Server for the duration of a transaction?</p>