Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 469
  • Last Modified:

SSRS - Using Microsoft Visual Studio

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
HelpMeWithSolutions
Asked:
HelpMeWithSolutions
1 Solution
 
dbaSQLCommented:
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
 
ZtinelCommented:
try this:
SELECT
SUBSTRING ((SELECT names + ', ' from workers for xml path('')), 1,
                     LEN((SELECT names + ', ' from workers for xml path('')))-2)
0
 
mlmccCommented:
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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now