Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.databases.ms-sqlserver > #717

Re: One more thing I don't understand in large Stored Procedure

From "Bob Barrows" <reb01501@NOSPAMyahoo.com>
Newsgroups comp.databases.ms-sqlserver
Subject Re: One more thing I don't understand in large Stored Procedure
Date 2011-10-02 15:25 -0400
Organization A noiseless patient Spider
Message-ID <j6adqd$1c5$1@dont-email.me> (permalink)
References <lf7h87lipni429qkdkfp09gskcuaj8nk7q@4ax.com> <j6a7u8$np2$1@dont-email.me> <aa9h87l9p368vnjhg28h42kblk9mev6b4u@4ax.com>

Show all headers | View raw


Tony C. wrote:
> 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. 

Back to comp.databases.ms-sqlserver | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

One more thing I don't understand in large Stored Procedure Tony C. <me@here.com> - 2011-10-02 12:34 -0500
  Re: One more thing I don't understand in large Stored Procedure "Bob Barrows" <reb01501@NOSPAMyahoo.com> - 2011-10-02 13:44 -0400
    Re: One more thing I don't understand in large Stored Procedure Tony C. <me@here.com> - 2011-10-02 12:47 -0500
    Re: One more thing I don't understand in large Stored Procedure Tony C. <me@here.com> - 2011-10-02 13:05 -0500
      Re: One more thing I don't understand in large Stored Procedure Erland Sommarskog <esquel@sommarskog.se> - 2011-10-02 20:31 +0200
        Re: One more thing I don't understand in large Stored Procedure Tony C. <me@here.com> - 2011-10-02 13:32 -0500
          Re: One more thing I don't understand in large Stored Procedure Henk van den Berg <me@myplace.net> - 2011-10-02 21:28 +0200
      Re: One more thing I don't understand in large Stored Procedure "Bob Barrows" <reb01501@NOSPAMyahoo.com> - 2011-10-02 15:25 -0400
        Re: One more thing I don't understand in large Stored Procedure Tony C. <me@here.com> - 2011-10-02 15:31 -0500

csiph-web