We are fighting this problem:
- We have a big table in
SQL Server 2008 R2(R2 !) (millions of rows) - We need to walk through this table and each row needs to be recomputed by a
C#code (so the table is loaded fromC#application)
How to do that if performance is crucial? Some kind of batching?
If performance is crucial, use SQL CLR to compute the new values. You can just use an update statement that way. SQL CLR places restrictions on what code you can use so this might not be an easy option.
There is another way if SQL CLR is not an option:
I assume there is an integer primary key. I’d do it like this:
The trick is to keep track of which rows you already processed. Keep the ID value of the last row processed. Request a batch like this:
That will guarantee fast an reliable execution.