Sequential update operations

When using multiple SETs for a single update request, for example

update table set col1=value1,col2=col1

Is there an execution order that will determine the result when the same column is to the left or right of the equal sign? As far as I have tested so far, it seems that the column is used to the right of the equal as a data source, then its value is used because it receives a new value within the same update statement, to the left of the equal sign in another place .

+3
source share
1 answer

, SQL Server UPDATE. , :

col1 | col2
1    | 3
2    | 8
3    | 10

update table set col1=value1,col2=col1

UPDATE :

col1   | col2
value1 | 1
value1 | 2
value1 | 3

UPDATE SQL ANSI-92, SO :

SQL UPDATE

, :

http://dba.fyicenter.com/faq/sql_server/Using_Old_Values_to_Define_New_Values_in_UPDATE_Statements.html

, SQL Server - UPDATE UPDATE.

+3

Source: https://habr.com/ru/post/1678401/


All Articles