1

I would like to export an SSRS report to a CSV file. Sounds simple, but I do not know how to add double quotes to the column headers in the exported CSV file. For example:

"UserName"|"UserAdd"
"Mike"|"Some Address"
1

The only way I have seen this work is by adding the double quotes inside the report yourself, but that can be a bit tedious if you have many textboxes and many reports.

Something like this should work though:

=IIF(Globals!RenderFormat.Name = "CSV",  """" & CStr(Fields!MyField.Value) & """", Fields!MyField.Value)

This code checks to see if it's being rendered to csv and adds the quotes if that's the case.

  • This does not work (at least with my ReportServerConfig). Using =iif(Globals!RenderFormat.Name = "CSV", """" & "Value" & """", "Value") returns as """Value""" – BishNaboB Feb 10 '17 at 10:56
0

Try encapsulating the column name (including double quotes) in square brackets, like ["ColumnName"].

This SQL query works in SSMS, so it might work for you too:

SELECT ["ColumnName"] = ColumnData
FROM Table_ABC

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.