title: Snapshot on, still deadlocks, ROWLOCK
body: <p>I turned snapshot isolation on in my database using the following code</p>
  
  <pre><code>ALTER DATABASE MyDatabase
  SET ALLOW_SNAPSHOT_ISOLATION ON
  
  ALTER DATABASE MyDatabase
  SET READ_COMMITTED_SNAPSHOT ON
  </code></pre>
  
  <p>and got rid off lots of deadlocks.</p>
  
  <p>But my database still produces deadlocks, when I need to run a script every hour to clean up 100,000+ rows. </p>
  
  <ul>
  <li>Is there a way I can avoid deadlocks in my cleanup script, do I need to set ROWLOCK specifically in that query?</li>
  <li>Is there a way to increase the number of row level locks that a database uses? </li>
  <li>How are locks promoted? From row level to page level to table level? </li>
  </ul>
  
  <p>My delete script is rather simple:</p>
  
  <pre><code>delete statvalue
  from statValue,
  (select  dateadd(minute,-60, getdate()) as cutoff_date) cd
  where temporaryStat = 1
  and entrydate &lt; cutoff_date
  </code></pre>
  
  <p>Right now I am looking for quick solution, but a long term solution would be even nicer.</p>
  
  <p>Thanks a lot,
  Patrikc</p>