---
title: "How to bulk update multiple rows in SQL Server at a time with different matching conditions?"  
description: "How to bulk update multiple rows in SQL Server at a time with different matching conditions?"  
author: "Steilla Mitchel"  
published: 2023-07-30  
updated: 2023-07-31  
canonical: https://www.mindstick.com/forum/159373/how-to-bulk-update-multiple-rows-in-sql-server-at-a-time-with-different-matching-conditions  
category: "mssql server"  
tags: ["mssql server", "sql server", "sql"]  
reading_time: 2 minutes  

---

# How to bulk update multiple rows in SQL Server at a time with different matching conditions?

How to [bulk](https://answers.mindstick.com/qa/116560/which-bulk-email-marketing-services-offer-high-delivery-low-cost) [update](https://www.mindstick.com/forum/156353/what-is-hummingbird-update) [multiple rows](https://www.mindstick.com/forum/160908/how-to-concatenate-text-from-multiple-rows-into-a-single-text-string-in-sql-server) in [SQL Server](https://www.mindstick.com/articles/12999/what-is-table-valued-function-in-sql-server) at a time with different matching [conditions](https://www.mindstick.com/blog/394/javascript-if-else)?

## Replies

### Reply by Aryan Kumar

Sure, here is how to bulk update [multiple](https://www.mindstick.com/blog/12797/iowa-is-expected-to-see-heavy-growth-in-multiple-sectors) rows in [SQL](https://www.mindstick.com/articles/13115/types-of-keys-in-sql-or-oracle-database) [Server](https://www.mindstick.com/articles/43769/what-is-serverless-architecture-is-it-worth-switching-over) at a time with different matching conditions:

SQL

```plaintext
USE MyDatabase;

UPDATE Customers
SET
  FirstName = CASE CustomerID
    WHEN 1 THEN 'John'
    WHEN 2 THEN 'Jane'
    ELSE FirstName
  END,
  LastName = CASE CustomerID
    WHEN 1 THEN 'Doe'
    WHEN 2 THEN 'Doe'
    ELSE LastName
  END
WHERE CustomerID IN (1, 2);
```

This code will update the `Customers` table to change the first and last names of the customers with the IDs 1 and 2. The `CASE` statement is used to specify different values for the `FirstName` and `LastName` columns, depending on the value of the `CustomerID` column. The `WHERE` clause is used to specify that the updates should only be applied to the rows where the `CustomerID` column is equal to 1 or 2.

The `UPDATE` statement can also be used to update multiple rows with the same value for a particular column. For example, the following code would update the `CustomerID` column of all rows in the `Customers` table to 100:

SQL

```plaintext
UPDATE Customers
SET CustomerID = 100;
```

The `UPDATE` statement is a powerful tool for updating data in SQL Server. It can be used to update a single row or multiple rows, and it can be used to update a single column or multiple columns.


---

Original Source: https://www.mindstick.com/forum/159373/how-to-bulk-update-multiple-rows-in-sql-server-at-a-time-with-different-matching-conditions

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
