Promotic
WikipediaLinkedInYoutubeTwitterFacebook

UPDATE - statement of language DB_MSSQL

Description:
Change values in the existing table record.
Syntax:

UPDATE table_name

SET column_name = expression | NULL | DEFAULT ] [, ...]

[ FROM table_source ]

[ WHERE search_condition ]

 
table_name Name of the table.
column_name Name of the column into which a new value will be entered.
expression The own value for the appropriate column determined by an expression.
table_source Name of the table that will be used for getting criteria of changing values.
search_condition Logical expression that determines which rows of the table are being changed (if WHERE is not stated, it means all records).
See also:
Example1:
Change the value of the column 'flags' for all records to the value 1.
UPDATE data SET flags=1
Example2:
Change the value of the column 'flags' for the record that is specified by the precise time to the value 2.
UPDATE data SET flags=2 WHERE time='2003-07-02 10:02:00.227'
Example3:
Change the value of the column 'flags' for the first record that meets the criterion that the value 'time' is greater than the specified time.
UPDATE data SET flags=3 FROM (SELECT TOP 1 * FROM data ORDER BY time) AS d1 WHERE data.time=d1.time
© MICROSYS, spol. s r. o.Tavičská 845/21 703 00 Ostrava-Vítkovice