I am trying to write a statement that will update multiple records into a table in a single SQL
statement.
I know there is multiple SO threads and other web sites addressing this batch Insert
statements, but I can't find one that I can understand enough for me to manipulate the statement to work for me.
The single Update
statement is simple enough
UPDATE [dbo].[ShiftTimes]
SET SubSection = 'One'
WHERE ID = '9E3C491A-3FE1-47F1-B701-000009C08CD0'
And to illustrate what I am trying to do (With incorrect syntax)
UPDATE [dbo].[ShiftTimes]
SET SubSection = 'One', 'Two', 'Three'
WHERE ID = '9E3C491A-3FE1-47F1-B701-000009C08CD0', '10F9F862-4723-4105-A8E9-000017097EBE', '25810E61-8E86-432B-9387-00003048E74D'
So basically I am trying to do this, in one statement
Where ID = '9E3C491A-3FE1-47F1-B701-000009C08CD0' Then set SubSection = 'One'
Where ID = '10F9F862-4723-4105-A8E9-000017097EBE' Then set SubSection = 'Two'
Where ID = '25810E61-8E86-432B-9387-00003048E74D' Then set SubSection = 'Three'
I thought I could do something like what is in this thread SQL Insert Into with Inner Join, but again, I can't see how I would be able to apply it to my situation?
Any help would be greatly appreciated.
EDIT: I apologize if this changes the question too much, but I am trying to update anywhere from 50,000 to 100,000 records and I am trying to optimize the code to Update
faster then looping over a single query and updating that way.