Solved

SSRS - Using Microsoft Visual Studio

Posted on 2011-03-23
4
467 Views
Last Modified: 2012-05-11
I hope you can help.

I am using SSRS MVS - to create reports. I want to be able to combine data from rows into 1 row with comma's.

ex.

table workers

  names
----------------
 John  
  nate
  bob

I like the output to be:

john, nate, bob

_________________

How can i achieve this ?

thanks
Ethan
0
Comment
Question by:HelpMeWithSolutions
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 17

Accepted Solution

by:
dbaSQL earned 500 total points
ID: 35204665
IF OBJECT_ID('workers','u')>0
DROP TABLE dbo.workers
GO
CREATE TABLE dbo.workers (workername varchar(10))
INSERT dbo.workers (workername)
SELECT 'John'
UNION
SELECT 'nate'
UNION
SELECT 'bob'


DECLARE @List varchar(2000)
SELECT @List = COALESCE(@List + ',', '') + workername
FROM dbo.workers

SELECT @List [List]
0
 
LVL 4

Expert Comment

by:Ztinel
ID: 35204999
try this:
SELECT
SUBSTRING ((SELECT names + ', ' from workers for xml path('')), 1,
                     LEN((SELECT names + ', ' from workers for xml path('')))-2)
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 35452399
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0

Featured Post

Veeam gives away 10 full conference passes

Veeam is a VMworld 2017 US & Europe Platinum Sponsor. Enter the raffle to get the full conference pass. Pass includes the admission to all general and breakout sessions, VMware Hands-On Labs, Solutions Exchange, exclusive giveaways and the great VMworld Customer Appreciation Part

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

622 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question