Reputation: 5737
I'm using SQL server 2008
I wrote a batch that exports store procedure resultes into csv file:
sqlcmd -S MyServer -d MyTable -E -Q "dbo.MySPname" -o "c:\\textfile4.csv" -h-1 -s"," -w 999 -W
1. When I open the output csv file I saw a break line in the middle of the row, like:
[Row 1]
[line 1]: col1_val, col2_val, col3_val, [line break]
[line 2]: col3_val,....
[Row 2]
[line 3]: col1_val, col2_val, col3_val, [line break]
[line 4]: col3_val,....
Whats wrong with my export?
Upvotes: 1
Views: 1225
Reputation: 5737
It was a line break in one of the fields
I solve that by adding
SELECT REPLACE(REPLACE(@str, CHAR(13), ''), CHAR(10), '')
Upvotes: 1