UPDATE (Searched) (E-SQL)

The UPDATE (Searched) statement changes data in existing rows of a table. UPDATE (Searched) is a standard Transact-SQL statement.

Syntax

UPDATE {table_name | view_name} SET [table_name. | view_name.] {column_name={expression | NULL | (select_statement)}[,...]} [FROM {table_name | view_name}[,...]] [WHERE search_condition]

Arguments
table_name
Is the table to be updated.
view_name
Is the view to be updated.
column_name
Is the column to be updated.
expression
Is the value of a particular column. This value must be an expression.
select_statement
Is a valid SELECT statement that returns a single row with a single column of data.
search_condition
Is any expression that can legally follow the standard Transact-SQL WHERE clause.
Remarks

Use UPDATE to change values. Use INSERT to add new rows.

Updating a varchar or text column with the empty string (' ') inserts a single space. All char columns are padded to the defined length.

All trailing spaces are removed from varchar column data. Strings that contain only spaces are truncated to a single space.

The SQL batch size of 128 KB limits the maximum amount of data that you can alter with UPDATE. Because some memory is required for the query’s execution plan, the actual amount of data you can include in an UPDATE statement is somewhat less than 128 KB. For example, you can update one column of about 125 KB or two columns of about 60 KB each.

Examples

UPDATE authors SET au_fname = 'Fred' WHERE au_lname = 'White'

  

See Also

INSERT

  


(c) 1988-98 Microsoft Corporation. All Rights Reserved.