Reputation: 24394
We are fighting this problem:
SQL Server 2008 R2
(R2 !) (millions of rows)C#
code (so the table is loaded from C#
application)How to do that if performance is crucial? Some kind of batching?
Upvotes: 3
Views: 149
Reputation: 171216
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:
select top 10000 *
from T
where ID > @lastIDProcessed
order by ID
That will guarantee fast an reliable execution.
Upvotes: 2