title: Which one to chose - cursor vs WHILE loop in SQL Server for better performance?
body: <p>I came across below scenario, pseudo code version is</p>
  <pre><code>SELECT ProductID 
  FROM ABC table 
  WHERE (Some subquery)
  
  For each record
         get value1 from DEF table where(some subquery with ProductID)
         
         Insert (ProductID, Value1) into GHI table 
         Insert (ProductID, Value1) into JKL table
  End loop 
  </code></pre>
  <p>I have 3 following approaches</p>
  <ol>
  <li>Stored procedure with a cursor</li>
  <li>Stored procedure with a <code>While</code> loop</li>
  <li>a) Stored procedure to Get Product IDs<br />
  b) C# Loop<br />
  c) Stored procedure to insert data into tables</li>
  </ol>
  <p>Which is the best approach in these or Is there any other best approach?</p>
  <p><strong>Note</strong>: This block code executed only once per day. There will be around 500 <code>ProductID</code>s on average per day.</p>