What is the order of evaluation in the following query:
UPDATE tbl SET q = q + 1, p = q;
That is, will \"tbl\".\"p\" be set to
The UPDATE does not see the results of its work.
p will be set to q as of before update.
The following code will just swap the columns:
DECLARE @test TABLE (p INT, q INT)
INSERT
INTO @test
VALUES (2, 3)
SELECT *
FROM @test
p q
--- ---
2 3
UPDATE @test
SET p = q,
q = p
SELECT *
FROM @test
p q
--- ---
3 2