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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple Selects into a Variable

Status
Not open for further replies.

NiceArms

Programmer
May 21, 2009
105
GB
I am trying to place a several SELECT CASE statements into a variable and I am not having much luck.

Example follows:

SELECT CASE WHEN LEN(Field1) <21 THEN field1 + SPACE(20 - LEN(field1 )) END,
CASE WHEN Field2 = 'X' THEN 'Y'
FROM Table1

Note: this query returns several records.

How do I get the information into the variable to that i can start "playing" with the data?

/Nice
 
You can't. The variable always will get value from the last record in the recordset.
But why you need variable? you can use that query as a derived table in your main SELECT.

Borislav Borissov
VFP9 SP2, SQL Server 2000/2005.
 
Thank you for confirming my thoughts.

believe it or not 10 minutes after posting this query I figured it out!

typical ay :D

/Nice
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top