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

combining a List with a Select statement..how?

Status
Not open for further replies.

Pandyon

Programmer
Feb 21, 2001
38
0
0
US
I've got a convoluted Select statement gathering lots of info from a variety of tables.

Abbreviated, I've written something like this:

Select master_customer_id, name, title, company, user
FROM cus_table
WHERE name LIKE 'A%'


On a separate piece of code, I'm using this nice little snippet to turn query results from a separate table directly to a list.

DECLARE @List varchar(2000)
SET @List = ''
SELECT @List = @List + Cast(demo_sub As varchar(20)) + ', '
FROM User_demo
WHERE (master_customer_id = xxxxxxx) AND (demo_code = 'contracts')

SET @List = SUBSTRING(@List, 1, Len(@List) - 1)

SELECT @List As 'List'

Is there a way to push this list into a new column in my original Select sql statement? To somehow combine the two?



I searched this forum and the Internet and can't find any info on combining these two processes.
Thanks.
 
Use a function.

Read this to see how I would approach this:
thread183-1159740



-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top