I have a large number of similar but unique update statements, where the same fields are being updated with different values, ie.
UPDATE tbl SET field1 = "x" WHERE pk = 1;
UPDATE tbl SET field1 = "y" WHERE pk = 2;
These are being sent as parameterised queries using DbCommand. Is there anything I can do to combine these, or otherwise optimise the update process?
2
Answers
I can confirm that @MarcGravell's comment above does work, and allows me to concatenate queries even when the updated fields are different in each query.
You could use a joined update with a
VALUES
clause