Sitecore Rocks Query Analyzer: Export data to CSV with commas in data

I was recently trying to output all items of a particular template using Sitecore Rocks Query Analyzer. I was able to create the query easy enough:

select @ContentTitle, @Date, @Tags, @Authors from /sitecore/content/Global/SharedContent/Publications//*[@@TemplateName='Publication']

However when I went to import the data into a CSV file I realized that both ContentTitle and Authors fields contained potential commas. Unfortunately, the program didn't handle it properly so I had to find a work around. ReplaceString function to the rescue!

select ReplaceString(@ContentTitle,",","#") as Title, @Date, @Tags, ReplaceString(@Authors,",","#") as Authors from /sitecore/content/Global/SharedContent/Publications//*[@@TemplateName='Publication']


What I ended up doing was simply replacing the commas with another character. Then when I opened the file in Excel, I replaced the characters back to the original values.

Nothing amazing in this post - but worth noting in case anyone else encounters this problem.

Comments