Steps to do Batch Update

Step 1: Create a database named EmployeeDetails.

CREATE TABLE Employees ( EmployeeID INT PRIMARY KEY, FirstName VARCHAR(50),
LastName VARCHAR(50), City VARCHAR(50), Department VARCHAR(50), Salary DECIMAL(10, 2));

Step 2: Create a table Name Employee having EmployeelD, FirstName, LastName, City, Department, Salary.

Step 3: Add 15 records to the table.

INSERT INTO Employees (EmployeeID, FirstName, LastName, City, Department, Salary) VALUES
(1, 'Aarav', 'Sharma', 'Mumbai', 'IT', 50000.00),
(2, 'Aaradhya', 'Patel', 'Delhi', 'HR', 55000.00),
(3, 'Vihaan', 'Gupta', 'Bangalore', 'Finance', 48000.00),
(4, 'Saisha', 'Singh', 'Kolkata', 'IT', 52000.00),
(5, 'Arnav', 'Chopra', 'Chennai', 'Marketing', 49000.00),
(6, 'Aadhya', 'Kumar', 'Hyderabad', 'Sales', 48000.00),
(7, 'Advait', 'Malhotra', 'Pune', 'IT', 53000.00),
(8, 'Ananya', 'Verma', 'Ahmedabad', 'Finance', 51000.00),
(9, 'Reyansh', 'Yadav', 'Jaipur', 'Marketing', 48000.00),
(10, 'Riya', 'Gupta', 'Lucknow', 'HR', 54000.00),
(11, 'Ishaan', 'Shah', 'Surat', 'Sales', 50000.00),
(12, 'Kavya', 'Mishra', 'Nagpur', 'Finance', 49000.00),
(13, 'Aarush', 'Singh', 'Indore', 'Marketing', 52000.00),
(14, 'Ishani', 'Jain', 'Kanpur', 'HR', 51000.00),
(15, 'Vivaan', 'Saxena', 'Bhopal', 'Sales', 53000.00);

Output:

Step 4: Update for single row and single column:

Update Employees set FirstName='Poki'
where EmployeeID=1;

Output:

As shown in the output below here single column that is FirstName of the table has been updated instead of all the columns in a single row.

Step 5: Update single row multiple columns:

Update Employees set FirstName='PokiMon', LastName='Anthony' ,
City='Pune',Department='HR', Salary=47000.00
where EmployeeID=1;

Output:

As shown in the output below here all the columns of the single row have been updated.

How to Perform Batch Updates in SQL Server

The Update statement is a SQL keyword to update data in the database. We can update all the rows in the database or some values with the help of conditions. The update is a SQL keyword, and it falls under Data Manipulation Language (DML), as the name suggests it is used to manipulate the data.

Updating a single row at a time is a lengthy and time-consuming process. So, we have another term known as “Batch Update“, in which we can update multiple rows in a single batch at a time. It reduces the time to update multiple records.

Similar Reads

How to Perform Batch Updates in SQL Server

To perform batch updates in SQL Server, use the UPDATE statement with a WHERE clause to specify the conditions for the batch, updating multiple rows at once....

Steps to do Batch Update

Step 1: Create a database named EmployeeDetails....

Batch Update Examples

Step 5: Batch update...

Conclusion

Batch update is used to update the large numbers of data in a data. It reduces the time to update multiple records in a large set of databases. It includes multiple update queries in a single operation to update the records. It enhances the performance and reduces the lock contention. It is one of the best techniques to update multiple records as it maintains data consistency and integrity....