In this tutorial we will learn how to update a record or row in SQL Server by using update keyword with example.
SQL UPDATE statement is used to modify the existing records in a table. Which record is to be update it is decided by a condition. To specify condition, we use WHERE clause. If you used WHERE clause with UPDATE query to update selected records otherwise, all the records would be affected.
The basic syntax of UPDATE query with WHERE clause is as follows:
SET column1 = value1, column2 = value2...., columnN= valueN
The PRODUCT table having the following records:
example, which would update ProductName for a Product which ID is 1.
UPDATE PRODUCT SET ProductName='Acer Laptop' where ProductId=1
Now, Product table would have the following records:
Note: You can also update multiple columns at a time to the selected records.