April 4, 2007 at 4:45 pm
Hi,
I have this table:
ID Value
1 A
1 B
2 C
2 B
3 C
3 A
3 B
4 C
I would like to get the above table in the form:
ID Value
1 A,B
2 C,B
3 C,A,B
4 C
Please let me know regarding this.
Thanks.
April 4, 2007 at 4:50 pm
You need to write a function that takes in the ID and returns a concatenated string of Values. create a function with something like this:
declare @res varchar(100)
select @res = isnull(@res,'' ) + ',' + value from yourtable where Id = @t
return @res
then call the function in the SELECT as
SELECT ID, dbo.fnGetValues(Id)
FROM yourTable
******************
Dinakar Nethi
Life is short. Enjoy it.
******************
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy