Say, if I have the following t-SQL statement (designed to run on SQL Server 2008):
UPDATE tbl
SET col1 = (
SELECT MAX(col1) FROM tbl AS t1 WHERE t1.type = tbl.type
);
How exactly does SELECT work in this case:
It selects taking into account the results of each UPDATE, or
It selects from the tbl as it was before the UPDATE began updating records.
Can someone clarify this for me?
2! Your subquery SELECT pulls the value as determined before the UPDATE makes any changes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With