April 6, 2012 at 6:06 am
I have a dataset in a table in a proc.
TABLEA
productid, OrganizationID, other columns.......
1 101
2 102
3 103
1 201
2 202
3 203
....
....
....
I want to display a comma separated list of Organization id's sharing the same productid
so the result set should be
productid, OrganizationIDList
1 101, 201,.....
2 102, 202.......
3 103, 203........
this makes my productID's unique for a list of Orgs..
I want avoid cursor ....any tricks gurus ?
April 6, 2012 at 6:09 am
Google some FOR XML PATH queries and you'll crack this soon enough.
The absence of evidence is not evidence of absence.
Martin Rees
You can lead a horse to water, but a pencil must be lead.
Stan Laurel
April 6, 2012 at 8:44 am
http://www.sqlservercentral.com/articles/comma+separated+list/71700/[/url]
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply