Saturday, February 25, 2012

pass a value other than a recordset from a stored proc

Ok I need to pass a value bask the my program that isnt the result of a quer
y
"but is the outcome of a query"
for instance:
if exists (SELECT email, phone
FROM users
WHERE (email = N'jim@.jones.com')
or (phone= N'1234567'))
return the vale true
else
return the value false
thanks
marcel> if exists (SELECT email, phone
> FROM users
> WHERE (email = N'jim@.jones.com')
> or (phone= N'1234567'))
> return the vale true
> else
> return the value false
if exists (SELECT email, phone FROM users WHERE (email =
N'jim@.jones.com') or (phone= N'1234567'))
return 1
else
return -1
"Marcel" <Marcel@.discussions.microsoft.com> wrote in message
news:16F8A659-1E78-4FE5-9C33-B6273C87575D@.microsoft.com...
> Ok I need to pass a value bask the my program that isnt the result of a
> query
> "but is the outcome of a query"
> for instance:
>
> if exists (SELECT email, phone
> FROM users
> WHERE (email = N'jim@.jones.com')
> or (phone= N'1234567'))
> return the vale true
> else
> return the value false
>
> thanks
> marcel
>|||You can either use Output variables or return values? The usage of
these depend on your programming language:
That=B4ll be in C#:
SqlParameter param =3D cmd.Parameters.Add("@.SomeOutputParam",
SqlDbType.Int);
param.Direction =3D ParameterDirection.Output;
param =3D cmd.Parameters.Add("@.SomeOutputParam", SqlDbType.VarChar);
For the return value that=B4ll be:
SqlParameter returnValue =3D
sqlCommand.Parameters.Add("@.ReturnValue",SqlDbType.Int);
returnValue.Direction =3D ParameterDirection.ReturnValue;
return (Int32)returnValue.Value;
HTH, Jens Suessmeyer.

No comments:

Post a Comment