Update multiple rows with different values in SQL

sql, sql-update

Solution

UPDATE T
SET Size = CASE SKU
    WHEN 'A' THEN 20
    WHEN 'B' THEN 10
    WHEN 'C' THEN 30
    WHEN ...
END

Or there may be a formula for calculating the size, but you've failed to give it in your question (Or we may have to switch to a more complex CASE expression, but again, too little detail in the question).

Problem

I have a table like this: ``` SKU Size A 10 B 10 C 10 D 10 E 10 F 10 G 10 ``` I want to change it to: ``` SKU Size A 20 B 10 C 30 D 10 E 80 F 10 G 60 ``` I have more than 3000 rows of records to update. How can I do that with SQL update command ?

Original source