update (core)

Description

Changes existing rows by adding data or modifying existing data.

Syntax

Transact-SQL Syntax

update [[database.]owner.]{table_name | view_name}
set [[[database.]owner.]{table_name. | view_name.}]
 column_name1 =
 {expression1 | NULL | (select_statement)}
 [, column_name2 =
 {expression2 | NULL | (select_statement)}]...
[from [[database.]owner.]{view_name | table_name
[(index index_name [prefetch size][lru | mru])]}
 [, [[database.]owner.]{view_name | table_name
[(index index_name [prefetch size][lru | mru])]}]...]
 [where search_conditions]

ODBC Syntax

UPDATE table_name
SET column_identifier={expression|NULL}
 [,column_idenfifier={expression|NULL}]...
[WHERE search_condition]

Parameters

set

specifies the column name and assigns the new value. The value can be an expression or a NULL. More than one column name or value pair must be separated by commas.

where

is a standard where clause.

Examples

Example 1

update authors
 set au_lname = “MacBadden”
 where au_lname = “McBadden”

Usage