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!

Return Multi Rows to one Colunm 1

Status
Not open for further replies.

Kenos

Programmer
Jul 21, 2002
28
0
0
US
Hello Every one,

I have a table that has four records in it

ID, Item , ItemName
Values
1, type1, Name1
2, type2, Name2
3, type3, Name3
4, type4, Name4

Output Needed Is this
ID, ItemName
1,'name1,Name2,name3,Name4'

Thanks in advance
Any help would be greatly appreciated


 
I'm not sure how you're linking ID of "1" to all the names, but I hope the below helps.

Code:
declare @names varchar(256)

select @names = @names + ItemName
from table

select 1, @names
 
Thank You for your response dky1e

When I first tried it it returned a null value

Then I added this to it

declare @names varchar(256)
Select @Name = ''
select @names = @names + ItemName + ','
from table

select 1 As ID, @names As Items

And it worked Great
Thanks for all your Help
(Mental Blocks Stink)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top