Solved

SSRS - Using Microsoft Visual Studio

Posted on 2011-03-23
4
465 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
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 100

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

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Need a SQL Server 2014 plug-in to scan the DB schema 4 59
Publishing SSRS Reports to an IIS Server 3 112
Query to return total 6 24
Sql Server group by 10 48
Introduction Earlier I wrote an article about the new lookup functions (http://www.experts-exchange.com/A_3433.html) that ship with SQL Server 2008 R2.  In this article I’m going to show you another new feature of SSRS 2008 R2, this time in the vis…
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.

740 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