Updating data in SQL Server database tables
You use the UPDATE
statement to modify an existing table data.
To execute the UPDATE
statement, a user must have at least an UPDATE
permission assigned on the target table.
The following is the basic syntax for the UPDATE
statement:
[WITH <common_table_expression> [, ...n]] UPDATE [TOP (expression) [PERCENT]] table_name | view_name | rowset_function | common_table_expression [WITH table_hint] SET column_name = {expression | DEFAULT | NULL} [ ,...n ] <outputclause> FROM < table_name | view_name | common_table_expression> WHERE <search_condition>
The following are the arguments of the UPDATE
statement:
WITH
: This keyword specifies the CTE that you can reference in yourUPDATE
statementTOP
: You specify this keyword to only update a specific number or percent of rows from the top of the querytable_name | view_name | rowset function | common_table_expression
: This specifies the name of the table, view, rowset function, or CTE that...