Tony C. wrote:
Quote:
However, this does return a resultset.
select @BeginProcessControlDate as BeginProcessControlDate,
@EndProcessControlDate as EndProcessControlDate,
count(*) as UsageGroupCount
from CabsUsageGroupHC;
only diff is SELECT @variable AS instead
of SELECT @variable =
could that be the difference? |
Almost, but not quite. These two statements are equivalent:
select @BeginProcessControlDate as BeginProcessControlDate
select BeginProcessControlDate = @BeginProcessControlDate
The point is, you have to analyze what is happening. In both of these
statements, a column called "BeginProcessControlDate" is being created, set
to the value of @BeginProcessControlDate, and being returned in the
resultset.
With a statement like:
select @BeginProcessControlDate = BeginProcessControlDate
the variable @BeginProcessControlDate is being assigned the value contained
in a table column called BeginProcessControlDate. If that column does not
exist in the table, an error will result.
So it's not simply a matter of looking for select clauses containing "="
operators as opposed to "AS" operators. You have to analyze what the
statements are doing.