SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Concatenating Field Values


Concatenating Field Values

Author
Message
Devo_SQL
Devo_SQL
SSC Rookie
SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)

Group: General Forum Members
Points: 29 Visits: 124
Is it possible to concatenate rows from a field in a dataset? I've done the following before with parameters:

=Join(Parameters!Location_ID.Label, ", ")

However, I would like to concatenate with fields like the following SubReport, but am receiving an "#Error":

=JOIN(Fields!Source.Value, ", ")

Any ideas? Thanks!
Jeff Moden
Jeff Moden
SSC Guru
SSC Guru (85K reputation)SSC Guru (85K reputation)SSC Guru (85K reputation)SSC Guru (85K reputation)SSC Guru (85K reputation)SSC Guru (85K reputation)SSC Guru (85K reputation)SSC Guru (85K reputation)

Group: General Forum Members
Points: 85390 Visits: 41078
Perhaps you can modify the following technique... dunno if it'll actually work in Reporting Services but, rumor has it that you can make queries and functions part of the works...

http://www.sqlservercentral.com/articles/Test+Data/61572/

--Jeff Moden

RBAR is pronounced ree-bar and is a Modenism for Row-By-Agonizing-Row.
First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column.
If you think its expensive to hire a professional to do the job, wait until you hire an amateur. -- Red Adair

Helpful Links:
How to post code problems
How to post performance problems
Forum FAQs
bledu
bledu
Ten Centuries
Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)

Group: General Forum Members
Points: 1131 Visits: 104
do it and see if you get an error.


Everything you can imagine is real.

Devo_SQL
Devo_SQL
SSC Rookie
SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)

Group: General Forum Members
Points: 29 Visits: 124
I'd like to perform the report formatting using SSRS expressions if possible, but maybe I'll end up doing it in the SQL code if I can't find another way. No one knows of a way to take a dataset and concatenate a series of column/row values into one string?
DamienB
DamienB
Valued Member
Valued Member (68 reputation)Valued Member (68 reputation)Valued Member (68 reputation)Valued Member (68 reputation)Valued Member (68 reputation)Valued Member (68 reputation)Valued Member (68 reputation)Valued Member (68 reputation)

Group: General Forum Members
Points: 68 Visits: 142
G'day mate,

I'm not sure if I'm interpreting the question correctly... But I'll throw this out there Smile I do some schools work, so here I am representing:

"Amazing Super School Semester:1 Term:1 Week:4 @ 20/06/2008 7:39:49 AM"

=First(Fields!campus_name.Value, "Attend_Days") & 
" Semester:" & Parameters!semester.Value &
" Term:" & Parameters!term.Value & " Week:" & Parameters!week.Value & " @ " & Globals!ExecutionTime



By using the ambasand? (&) I can string SSRS fields and plain text all together. Hope this helps BigGrin

- Damien
Devo_SQL
Devo_SQL
SSC Rookie
SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)

Group: General Forum Members
Points: 29 Visits: 124
No, not looking to simply concatenate strings, but the DataSet (array?) values. I am looking for a tool or method to iterate through the DataSet and concatenate all of the field values. I've done so with the JOIN method for parameter lists but this does not seem to work for DataSet field values.
Matt Miller (4)
Matt Miller (4)
SSChampion
SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)

Group: General Forum Members
Points: 12163 Visits: 18572
Devo - have you actually tried the methods in Jeff's article? There's no reason you couldn't use the function run against DISTINCT values in SSRS.

----------------------------------------------------------------------------------
Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?
Devo_SQL
Devo_SQL
SSC Rookie
SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)

Group: General Forum Members
Points: 29 Visits: 124
I did get Jeff's method to work in SQL Server Management Studio with the following code:

SELECT(STUFF((SELECT ', '+AS1.Source
FROM Agent_Source AS1 INNER JOIN
Agent_Source_Release ASR ON ASR.Agent_Source_ID = AS1.Agent_Source_ID
WHERE (Release_ID = @Release_ID)
FOR XML PATH('')),1,2,''))

However, when I moved the query into the SSRS dataset it wants me to declare the @Release_ID variable. SSRS has already created this variable for me but it continues to say it's not there.

I think the real problem is with the FOR XML PATH method. With even a simple select query I get the following error as soon as I add "FOR XML PATH('')" to the end of a statement:

"Unable to parse query text."
Jeff Moden
Jeff Moden
SSC Guru
SSC Guru (85K reputation)SSC Guru (85K reputation)SSC Guru (85K reputation)SSC Guru (85K reputation)SSC Guru (85K reputation)SSC Guru (85K reputation)SSC Guru (85K reputation)SSC Guru (85K reputation)

Group: General Forum Members
Points: 85390 Visits: 41078
I'd try to help... but I can't even spell SSRS, yet. Sorry...

--Jeff Moden

RBAR is pronounced ree-bar and is a Modenism for Row-By-Agonizing-Row.
First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column.
If you think its expensive to hire a professional to do the job, wait until you hire an amateur. -- Red Adair

Helpful Links:
How to post code problems
How to post performance problems
Forum FAQs
sparky-407434
sparky-407434
SSC Journeyman
SSC Journeyman (93 reputation)SSC Journeyman (93 reputation)SSC Journeyman (93 reputation)SSC Journeyman (93 reputation)SSC Journeyman (93 reputation)SSC Journeyman (93 reputation)SSC Journeyman (93 reputation)SSC Journeyman (93 reputation)

Group: General Forum Members
Points: 93 Visits: 494
Did anyone find a solution to this?
I would also like to concatenate like:
=Join(Fields!Total.value,",").
I also have did similar for parameter selections.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search