Sunday, February 12, 2012

comma separated value

Suppose I have a table like this

code Value
1 a
1 a
1 b
2 c
2 c
1 d
2 g

Now my require ment that I want a distinct comma separated report about these data.Means for code 1 I need a comma separated distinct values.In this case it should be a,b,d
My output should be like this
1 a,b,d
2 c,g
Can anybody help me I can I do this with the help of a cursor or any other way?
SubhasishOriginally posted by subhasishray
Suppose I have a table like this

code Value
1 a
1 a
1 b
2 c
2 c
1 d
2 g

Now my require ment that I want a distinct comma separated report about these data.Means for code 1 I need a comma separated distinct values.In this case it should be a,b,d
My output should be like this
1 a,b,d
2 c,g
Can anybody help me I can I do this with the help of a cursor or any other way?
Subhasish

there is an article explaining exactly what u are looking for :
http://www.sqlteam.com/item.asp?ItemID=256

Regards,
Harshal.

No comments:

Post a Comment