I'm using sqlcmd.exe to run a SQL script and route the output to a file. The SQL script that I'm running produces as it's output another SQL script, which can then be run to import/update information in another database (in fact, the script is querying extended properties and writing out a script that, when run, will create/update those extended properties. This script is then checked into source control as a part of the database documentation).
I'm having a hard time getting clean output from sqlcmd though.
If I use a plain invocation, I get huge long lines of output (the type of the expression that's being output is nvarchar(4000)).
If I use -y0 I get the same output as above.
If I use -Y0, I get huge long lines, with a full line of dashes (--------------) between the output that was produced by the several select statements that are present in the input file.
If I use -W, I get shortened lines (all the trailing whitespace removed), but I get a line consisting of a single dash (-) between the output that was produced by the various select statements in the input.
I need that line consisting of a single dash to go away - or change it to two or more dashes, making it a valid SQL comment.
For example:
-- Input file select 'select 1' select 'select 2' -- Output file - select 1 - select 2
Is there some option I've overlooked that will get rid of those infernal dashes?
-cd Mark the best replies as answers!