title: Deleting large number of rows in chunks
body: <p>I have about 8 tables that have 10 million rows or more each and I want to do the fastest/elegant delete on them. I have decided to delete them in chunks at a time. When I added my changes, it looks very very ugly, and want to know how to format it to look better. Also, is this the best way to be doing this?</p>
  
  <pre><code>DECLARE @ChunkSize int
  SET @ChunkSize = 50000
  
  WHILE @ChunkSize &lt;&gt; 0
  BEGIN
    DELETE TOP (@ChunkSize) FROM TABLE1
    WHERE CREATED &lt; @DATE
       SET @ChunkSize = @@rowcount
  END
  
  
  DECLARE @ChunkSize int
  SET @ChunkSize = 50000
  
  WHILE @ChunkSize &lt;&gt; 0
  BEGIN
    DELETE TOP (@ChunkSize) FROM TABLE2
    WHERE CREATED &lt; @DATE
       SET @ChunkSize = @@rowcount
  END
  .......
  </code></pre>
  
  <p>I would be doing this for all 8 tables which doesn't seem practical. Any advice on how to clean this up?</p>