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"
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It only takes a minute to sign up.Sign up to join this community
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.
Try encapsulating the column name (including double quotes) in square brackets, like
This SQL query works in SSMS, so it might work for you too:
SELECT ["ColumnName"] = ColumnData FROM Table_ABC