da-zero (10/29/2010)
Hardy21 (10/29/2010)
Thanks for the link. Hence, @a =+ @b-2 means @b-2 value assign to @a so @a = -21.Indeed. But why doesn't SQL Server give a syntax error? I would've liked that in the explanation.
Becuase there is no invalid syntax. Spaces are (mostly) ignored by SQL Server, so @a =+ @b-2 is equivalent to @a=+@b, or to @a = +@b. The latter alternative is the most human-comprehensible. @a is assigned the result of applying the unqry + operator on @B. (And since the unary + operator is basically a no-op, you simply assign @a the value of @b-2).