The SELECT
assigns value to @v1 and uses @v1 to compute @v2 in the same statement. The results are @v1 = 100 and @v2=105.
Are these results always guaranteed by SQL Server? Is it guaranteed by SQL server that when it is referring to @v1 for computing @v2, all the side effects of @v1 = 100 are complete and SQL server indeed read @v1 after all the side effects were complete?
Any corner cases where SQL server might give different results?
declare
@v1 int,
@v2 int
-- Let's keep the order of assignment as it is listed here.
select
@v1 = 100,
@v2 = @v1 + 5
select
@v1 as '@v1',
@v2 as '@v2'
I looked up MSDN, but find anything around this.