Trying to export a SQL Server database query results to a .csv file I have similarly output situation according to what it's presented here but having a different approach I open a new thread.
I have a complex query that has joins on few tables using some filters via some temporary tables. I am executing the stored procedure:
EXEC xp_cmdshell 'SQLCMD -S . -d myDATABASE -Q "EXECUTE myStoreProcedure;" -s " " -x -o "d:\result.csv"';
I get all the data into result.csv but the beginning of the file contains some
(10 rows affected)
(4 rows affected)
(23 rows affected)
(5 rows affected)
(8 rows affected)
(2 rows affected)
//followed by the header columns - as expected
----------------------------------------------------------------------
//and effective results - as expected
I would prefer not having output and dashed rows. I'm open to any suggestions / workarounds.