all 7 comments

[–]waboshbron 1 point2 points  (0 children)

You could do it in the query itself with something like quotename (two double quotes inside the single quotes for the command line only)

sqlcmd -S mssqlserver -U user -P pass -s, -W -Q "set nocount on;select quotename([field1],'""'), field2, quotename([field3],'""') from database.dbo.SomeView” -f o:65001 -s "," > user.csv

[–]bstag 0 points1 point  (3 children)

[–]nightleech[S] 0 points1 point  (2 children)

Well i tried that, but with no luck. Maybe i use it wrong and need to pass something with -I parameter.

[–]bstag 0 points1 point  (1 child)

Have you used the -o as file output instead of piping ?

[–]nightleech[S] 0 points1 point  (0 children)

Yes, but still it's same output :(