Why don't you try update table with where ? In the select statement of your question, you can declare Column1 , Column2 and Column3 as NULL , and the two update statements change the values.
With βonlyβ three columns, depending on the same case code below does not save much typing (maybe runtime ...?), But it works when you have more than 3 ...
UPDATE MyTable SET Column1 = lm.name, Column2 = '3', Column3 = 'True' WHERE lm.Id IN ('1','2','3') UPDATE MyTable SET Column1 = lm.Desc, Column2 = '1', Column3 = 'False' WHERE lm.Id NOT IN ('1','2','3')
source share