Stray control characters in CSV Export from Management Studio -
07-15-2008
, 08:26 AM
I have a very simple result set displayed in a Grid in Microsoft SQL
Server Management Studio (2005) that I want to save as a CSV file. I
right click on the grid, select Save Results As... and save the file.
The file looks like this in a text editor:
1,1,1
2,2,2
3,3,3
....
But when I try to open it in Excel, it's not parsed right. Examination
with a Hex editor shows a leading Hex ff fe, plus a null between each
character.
Here's what I got from Management Studio:
ff fe 31 00 2c 00 31 00 2c 00 31 00 0d 00 0a 00 32 00 2c 00 32 00 2c
00 32 00 0d 00 0a 00 33 00 2c 00 33 00 2c 00 33 00 0d 00 0a 00 34 00
2c 00 34 00 2c 00 34 00 0d 00 0a 00 35 00 2c 00 35 00 2c 00 35 00 0d
00 0a 00 36 00 2c 00 36 00 2c 00 36 00 0d 00 0a 00 37 00 2c 00 37 00
2c 00 37 00 0d 00 0a 00 38 00 2c 00 38 00 2c 00 38 00 0d 00 0a 00 39
00 2c 00 39 00 2c 00 39 00 0d 00 0a 00 31 00 30 00 2c 00 31 00 30 00
2c 00 31 00 30 00 0d 00 0a 00
This is what is normal:
31 2c 31 2c 31 0d 0a 32 2c 32 2c 32 0d 0a 33 2c 33 2c 33 0d 0a 34 2c
34 2c 34 0d 0a 35 2c 35 2c 35 0d 0a 36 2c 36 2c 36 0d 0a 37 2c 37 2c
37 0d 0a 38 2c 38 2c 38 0d 0a 39 2c 39 2c 39 0d 0a 31 30 2c 31 30 2c
31 30
It's a real pain not being to simply open these files in Excel.
Kevin |