Just trying to confirm what I think I am seeing...
If I run a query which does something like this...
Select @.MyField = UserName
from dbo.signon
running this SQL statement inside a procedure does not produce anything in
terms of output row set? Just trying to confirm, that the client
application which is calling this procedure would not get any rows returned
(in this portion of the code) and that it is just setting some @. variables
for my later use within the Proc. Is that correct?
It is apparently "illegal" for me to have a statement like the following:
Select @.MyField = UserName, password
from dbo.signon
This is not a "real" situation, I am just trying to understand what I can
do and what I can not do. When I try this, I get the following error "A
SELECT statement that assigns a value to a variable must not be combined
with data-retrieval operations.", which brings me to the conclusion that it
is illegal.
So in a situation where I needed to populate a "@.MyField" variable and also
retrieve the password (for some reason), this would be a two step process
(assuming no cursor logic)?
Thanks in advance for your assistance!!!!!!No rows will be returned to the client when you use SELECT to populate
variables. You can populate multiple variables concurrently:
Select @.MyField = UserName
, @.MyFiled2 = password
from dbo.signon
Note: If your select would retrieve multiple rows, then the results are
unpredictable.
Tom
---
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada
www.pinnaclepublishing.com/sql
"Jim Heavey" <JimHeavey@.nospam.com> wrote in message
news:Xns947E5CB70CF08JimHeaveyhotmailcom
@.207.46.248.16...
Just trying to confirm what I think I am seeing...
If I run a query which does something like this...
Select @.MyField = UserName
from dbo.signon
running this SQL statement inside a procedure does not produce anything in
terms of output row set? Just trying to confirm, that the client
application which is calling this procedure would not get any rows returned
(in this portion of the code) and that it is just setting some @. variables
for my later use within the Proc. Is that correct?
It is apparently "illegal" for me to have a statement like the following:
Select @.MyField = UserName, password
from dbo.signon
This is not a "real" situation, I am just trying to understand what I can
do and what I can not do. When I try this, I get the following error "A
SELECT statement that assigns a value to a variable must not be combined
with data-retrieval operations.", which brings me to the conclusion that it
is illegal.
So in a situation where I needed to populate a "@.MyField" variable and also
retrieve the password (for some reason), this would be a two step process
(assuming no cursor logic)?
Thanks in advance for your assistance!!!!!!
No comments:
Post a Comment