sql query update multiple rows code example

Example 1: set sql multiple values

UPDATE Person.Person
 Set FirstName = 'Kenneth'
    ,LastName =  'Smith'
 WHERE BusinessEntityID = 1

Example 2: update multiple columns in sql

UPDATE table-name SET column-name = value, column-name = value WHERE condition = value

Example 3: update table sql multiple set

-- CANT do multiple sets but can do case
UPDATE table
SET ID = CASE WHEN ID = 2555 THEN 111111259 
              WHEN ID = 2724 THEN 111111261
              WHEN ID = 2021 THEN 111111263
              WHEN ID = 2017 THEN 111111264
         END
WHERE ID IN (2555,2724,2021,2017)

Tags:

Sql Example