Sql-server – Export SSRS report to CSV

csvexportsql serverssrs

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"

Best Answer

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.