This rule allows you to update values on multiple rows in a single UPDATE statement.
There are multiple ways to use the UPDATE statement to update a SQL Server table.
In this article I will show you the most common methods of using the UPDATE statement.
In previous versions of SQL Server, if I needed to update numerous rows of data, I used a temporary table.
Suppose, for example, that thousands of transactions needed their transaction dates updated.
Because transaction logs are not recorded for table-valued parameters, performance improves.
Previously, when multiple values were involved, the insert statement was executed multiple times; now, I use a table-valued parameter—with numerous values—that’s treated as one value and requires only one insert statement.
To properly show you how to use the UPDATE statement I will need to create a few tables to hold some sample data. Below is the code to create my Toy table: In order to show you how to UPDATE a table from data in another table I need to build a second sample data table that I will call New Toy Price.
Below is the TSQL code to create and populate this table.
But, what you can do is pass in all the values you want to update as a table valued parameter. FROM statement that will enable you to update all the values based on the listing of values within the parameter.