On Sat, 02 Oct 2004 12:20:48 -0600, Otto Porter wrote:
I know, I can get this output just by adding
FK+WT. This is not about that.
This is about setting vars inside a query
Hi Otto,
It's not possible to change the value of a variable during the execution
of a SELECT statement. At least not the way you are trying to do it.
You can of course do
SELECT @var = ..., @var = ...
FROM table
WHERE ...
but I assume that this is not what you want. You can't mix this format of
the SELECT statement with a SELECT that outputs a result set.
The way I read your example, it would be very easy to have queries where
the result would be dependent on the order in which rows are processed by
SQL Server. Since SQL Server is entirely free in it's choice of processing
order, the results would be unexpected and might even vary from execution
to execution.
Check out the following link to find some good examples of the possible
effects of unexpected processing order on assignments with the SELECT
statement:
http://groups.google.com/groups?hl=e...TNGP12.phx.gbl
Best, Hugo
--
(Remove _NO_ and _SPAM_ to get my e-mail address)