Book Image

SQL Server 2014 Development Essentials

By : Basit A. Masood-Al-Farooq
Book Image

SQL Server 2014 Development Essentials

By: Basit A. Masood-Al-Farooq

Overview of this book

Table of Contents (14 chapters)
SQL Server 2014 Development Essentials
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

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 your UPDATE statement

  • TOP: You specify this keyword to only update a specific number or percent of rows from the top of the query

  • table_name | view_name | rowset function | common_table_expression: This specifies the name of the table, view, rowset function, or CTE that...