UPDATE Statement in SQL Server

Update statement is different from INSERT and DELETE statements.UPDATE statements is used for updating a single records to multiple records. UPDATE statements use a WHERE clause, same as SELECT statement.
UPDATE statements use a SET statement. SET statement involves single column or multiple column, means you can update the single column value or ,multiple column values on the basis of WHERE clause by using SET statement in UPDATE statement.

Suppose you have a table named tbl_employee:
 
tbl_employee

Employee IdEmpNameAgeDepartmentSalary
1Ankur28Sales2500.00
2David32Sales3000.00
3John30HR2200.00
5Mohan35Production4300.00

 

Now if you want to change the department of the John to Sales, you can use the following query:

UPDATE tbl_employee SET department='Sales' WHERE empname='John'

And now to see the changes run the ‘Select *‘ query as :

SELECT * FROM tbl_employee

tbl_employee

Employee IdEmpNameAgeDepartmentSalary
1Ankur28Sales2500.00
2David32Sales3000.00
3John30Sales2200.00
5Mohan35Production4300.00