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 Veteran
SSC Veteran (261 reputation)SSC Veteran (261 reputation)SSC Veteran (261 reputation)SSC Veteran (261 reputation)SSC Veteran (261 reputation)SSC Veteran (261 reputation)SSC Veteran (261 reputation)SSC Veteran (261 reputation)

Group: General Forum Members
Points: 261 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 (512K reputation)SSC Guru (512K reputation)SSC Guru (512K reputation)SSC Guru (512K reputation)SSC Guru (512K reputation)SSC Guru (512K reputation)SSC Guru (512K reputation)SSC Guru (512K reputation)

Group: General Forum Members
Points: 512945 Visits: 44331
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
SSCertifiable
SSCertifiable (7K reputation)SSCertifiable (7K reputation)SSCertifiable (7K reputation)SSCertifiable (7K reputation)SSCertifiable (7K reputation)SSCertifiable (7K reputation)SSCertifiable (7K reputation)SSCertifiable (7K reputation)

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


Everything you can imagine is real.

Devo_SQL
Devo_SQL
SSC Veteran
SSC Veteran (261 reputation)SSC Veteran (261 reputation)SSC Veteran (261 reputation)SSC Veteran (261 reputation)SSC Veteran (261 reputation)SSC Veteran (261 reputation)SSC Veteran (261 reputation)SSC Veteran (261 reputation)

Group: General Forum Members
Points: 261 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
SSC-Addicted
SSC-Addicted (420 reputation)SSC-Addicted (420 reputation)SSC-Addicted (420 reputation)SSC-Addicted (420 reputation)SSC-Addicted (420 reputation)SSC-Addicted (420 reputation)SSC-Addicted (420 reputation)SSC-Addicted (420 reputation)

Group: General Forum Members
Points: 420 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 Veteran
SSC Veteran (261 reputation)SSC Veteran (261 reputation)SSC Veteran (261 reputation)SSC Veteran (261 reputation)SSC Veteran (261 reputation)SSC Veteran (261 reputation)SSC Veteran (261 reputation)SSC Veteran (261 reputation)

Group: General Forum Members
Points: 261 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)
SSC Guru
SSC Guru (68K reputation)SSC Guru (68K reputation)SSC Guru (68K reputation)SSC Guru (68K reputation)SSC Guru (68K reputation)SSC Guru (68K reputation)SSC Guru (68K reputation)SSC Guru (68K reputation)

Group: General Forum Members
Points: 68606 Visits: 20015
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 Veteran
SSC Veteran (261 reputation)SSC Veteran (261 reputation)SSC Veteran (261 reputation)SSC Veteran (261 reputation)SSC Veteran (261 reputation)SSC Veteran (261 reputation)SSC Veteran (261 reputation)SSC Veteran (261 reputation)

Group: General Forum Members
Points: 261 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 (512K reputation)SSC Guru (512K reputation)SSC Guru (512K reputation)SSC Guru (512K reputation)SSC Guru (512K reputation)SSC Guru (512K reputation)SSC Guru (512K reputation)SSC Guru (512K reputation)

Group: General Forum Members
Points: 512945 Visits: 44331
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-Addicted
SSC-Addicted (415 reputation)SSC-Addicted (415 reputation)SSC-Addicted (415 reputation)SSC-Addicted (415 reputation)SSC-Addicted (415 reputation)SSC-Addicted (415 reputation)SSC-Addicted (415 reputation)SSC-Addicted (415 reputation)

Group: General Forum Members
Points: 415 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