I followed Export table from database to csv file and used this command line:
sqlcmd -S . -d DataBase -E -s, -W -u -Q "SELECT * FROM Table" > C:/Table.csv
But the file's second like is being used to separate first line's column names to third line's data:
-----------,------,-------,--------,------,------,------,-------,--------,---------,--------,---------,---------,----------
I aim to import this file on Excel PowerPivot, and can't figure a way to tell it that second line must be ignored.
Is there a way for MSSQL not print this separator line, or at least make PowerPivot ignore it?
Update, I was able to export data using the command
sqlcmd -S . -d APP_BI -E -s, -W -u -Q "SELECT * FROM DB.dbo.Table" | findstr /V /C:"-" /B > C:\Table.csv
executed from cmd.exe. But when I add it to to cmd file, or execute it directly from MSSQL Agent, I get error message Sqlcmd: '| findstr': Unexpected argument. Enter '-?' for help.
. So, pipe doesn't work inside a cmd file or from MSSQL Agent, they think it's a parameter for sqlcmd.
This leads me to begining, I need a way to generate the csv without that line.