In this article I will show you a number of different ways to use the UPDATE statement to modify the data in your SQL Server tables.
There are multiple ways to use the UPDATE statement to update a SQL Server table.
Suppose I wanted to change both the Toy Name and the Price columns.
I can update multiple columns with a single UPDATE statement.
If you incorrectly specify your search condition you might update too many rows, or not enough rows.
Additionally if you forget the WHERE clause altogether, you will update the entire table when you might not intend to.
Here is an example where I specified the WHERE clause incorrectly and I updated too many rows: Here I updated Toy Name on two rows, the “Silver Magic” and the “Super Surfer” Toyname rows.
I then used the New Toy Price column values for Toy Name and Price to update my Toy table column values on rows that have matching column ID values.
We have already seen how to limit the rows being updated by using the WHERE clause.