April 18, 2014 at 1:31 pm
Hi,
I have a requirement for SSRS report where part of the input has the following structure:
Store NumberStore Owner
542 Jaklin Givargidze
542 Raymond G. Givargidze
557 Hui Juan Lu
557 Tong Yu Lu
but the user would like to see the following:
Store Number Store Owner
542 Jaklin Givargidze, Raymond G. Givargidze
557 Hui Juan Lu, Tong Yu Lu
I am sure that this can be coded, just don't know how. I believe that proper term is to "serialize" the values. Any help would be greatly appreciated.
thanks,
Petr
April 18, 2014 at 2:14 pm
Take a look at this article. 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/
April 18, 2014 at 2:56 pm
see this..
DECLARE @Input TABLE
(
Store_Number INT,
Store_Owner VARCHAR(32)
)
INSERT INTO @Input VALUES(542, 'Jaklin Givargidze'), (542, 'Raymond G. Givargidze'), (557, 'Hui Juan Lu'), (557, 'Tong Yu Lu')
SELECT DISTINCT Store_Number,
STUFF((SELECT ','+Store_Owner
FROM @Input S2
WHERE S1.Store_Number = S2.Store_Number
FOR XML PATH('')), 1, 1, '') AS Store_Owner
FROM @Input S1
Good Luck 🙂 .. Visit www.sqlsaga.com for more t-sql code snippets and BI related how to articles.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply