I have an update statement in this form:
declare @v as int
update tbl
set @v=tbl.a=(select sum(amount) from anothertable at where at.x = tbl.y),
tbl.b = @v/2
The reason I would like to use a variable is to avoid using the subquery twice. The problem is that I have not found any references stating that this is safe. Is the second assignment (i.e. tbl.b = @v/2) always evaluated after the first assignment?
The order of evaluation for a select statement is not guaranteed. Is this also true for an update statement?
thanks a lot.