Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Variables in a procedure

Status
Not open for further replies.

aalnaif

Technical User
Jan 12, 2007
44
CA
What's the proper way to use a variable in a procedure?
Whenever I try and initialize one, I'm getting an error that I'm not using the proper syntax. Because I can't initialize it, whenever I try and use it I'm getting a null result. The variable is to be used inside a case when statement that first uses a select to check if something exists. Then, instead of running the select over again, I'd like just to return the variable.

right now all I have is

case when EXISTS(select @variable := column where CONDITIONS) then
@variable
when EXISTS(select @variable := column where OTHERCONDITIONS)
END

And it's not working.
Any tips or idea how to use the variables?
Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top