Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: "Bob Barrows" Newsgroups: comp.databases.ms-sqlserver Subject: Re: One more thing I don't understand in large Stored Procedure Date: Sun, 2 Oct 2011 15:25:18 -0400 Organization: A noiseless patient Spider Lines: 37 Message-ID: References: Injection-Date: Sun, 2 Oct 2011 19:25:01 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="inlgCTpOMxujS+VHkVo6dA"; logging-data="1413"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/7l8sCyXesQHnG+X5aWfKoWnFJDFivCnM=" X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6109 X-RFC2646: Format=Flowed; Original X-Antivirus-Status: Clean X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-Antivirus: avast! (VPS 111002-1, 10/02/2011), Outbound message Cancel-Lock: sha1:+CvX2GGphc5yT1BTqmyZjXPW4zk= X-Priority: 3 X-MSMail-Priority: Normal Xref: x330-a1.tempe.blueboxinc.net comp.databases.ms-sqlserver:717 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.