Donate

How To Update Multiple Rows In SQL Server Using One SQL Statement

Here's how to update multiple rows in one SQL statement using MSSQL.
UPDATE
  tblEmp
SET
  empSalary = empSrc.empSalary,
  empLevel = empSrc.empLevel
FROM
  dbo.tblEmployees AS tblEmp
  INNER JOIN
  (
    VALUES
    (001, 10000.00, 10),
    (002, 32000.00, 15),
    (003, 9500.00, 3)
  ) AS empSrc (empID, empSalary, empLevel)
    ON tblEmp.empID = empSrc.empID;
Reference: How to update multiple columns of multiple rows in one SQL statement

Comments

Donate

Popular Posts From This Blog

WPF CRUD Application Using DataGrid, MVVM Pattern, Entity Framework, And C#.NET

TypeScript Error Or Bug: The term 'tsc' is not recognized as the name of a cmdlet, function, script file, or operable program.

Invalid nested tag div found, expected closing tag input