title: Writing code to Process 25,000 records C#, T-SQL, Quick Performance is key
body: <p>What would be the most efficent way to Loop through 25,000 records, and based on some prewritten vb logic that wont ever change(99% sure), update the Result column in a table to a value of 1, 2 or 3?</p>
  
  <p>Performance and reliabilty is most important here. This most likely will get called via a client server app on the network but would be nice to be able to call it from a web app. I am thinking about 3 different ways to do it with T-SQL, C#.</p>
  
  <p>a. Write an object that executes a stored procedure  gets the 25,000 records, use the foreach collection to go through each record and based on some c# logic, call an object at each record that executes a stored procedure to update that row. This would call the object 25,000 times (and the proc I assume would just reuse the execution plan)</p>
  
  <p>or</p>
  
  <p>b. Write a stored procedure that gets the 25,000 records, use the forbidden cursor to go through each record and based on some T-SQL logic,  update that row in this stored procedure. </p>
  
  <p>or</p>
  
  <p>UPDATED: MY SOLUTION IS THIS
  For what it's worth I am going with persisited computed columns, and breaking the loop into smaller update statements to update the column (all wrapped in a transaction). See article below. I think it will be really fast, compared to a loop..</p>
  
  <p><a href="http://technet.microsoft.com/en-us/library/cc917696.aspx" rel="nofollow">http://technet.microsoft.com/en-us/library/cc917696.aspx</a></p>