Export (0) Print
Expand All

UPDATE

SQL Server 2000

Modifies existing data in a table in Microsoft® SQL Server™ 2000 Windows® CE Edition (SQL Server CE).

Syntax
UPDATE table_name 
   SET 
   { column_name = { expression | DEFAULT | NULL } } [ ,...n ] 
   [ WHERE < search_condition > ] 
Arguments
table_name
Is the name of the table to update.
SET
Specifies the list of column or variable names to be updated.
column_name
Is a column that contains the data to be changed. column_name must reside in the specified table and should be specified only once in the SET clause.
expression
Is a variable, literal value, or expression that returns a single value. The value returned by expression replaces the existing value in column_name.
DEFAULT
Specifies that the default value defined for the column is to replace the existing value in the column. This can also be used to change the column to NULL if the column has no default and is defined to allow null values.
WHERE
Specifies the conditions that limit the rows that are updated.
< search_condition >
Specifies the condition to be met for the rows to be updated. There is no limit to the number of predicates that can be included in a search condition.
Remarks

Identity columns cannot be updated.

If a WHERE clause is not specified, all rows of the table are updated.

The search condition in the WHERE clause is evaluated for each row of the table before updating any row of the table.

If an update to a row violates a constraint or rule, if it violates the NULL setting for the column, or if the new value is an incompatible data type, the statement is canceled, an error is returned, and no records are updated.

All nchar columns are right-padded to the defined length.

All trailing spaces are removed from data inserted into nvarchar columns, except in strings containing only spaces. These strings are truncated to an empty string.

Examples

The following example changes the shipping address in the Orders table of the Northwind database for all orders made by the company with the customer ID of VINET.

UPDATE Orders SET ShipAddress = '21 rue de l''xylophie' WHERE CustomerID = 'VINET'

Show:
© 2014 Microsoft