2
When I route the output of my queries to a file, there are one or two blank lines at the bottom. When I run the query though SSMS (2008 or 2012), I get two extra blank lines. When I run the query through SQLCMD, I get 1 extra blank line. How do I get rid of them?
Example (using SSMS):
Set NoCount on
Select '1' as 'One'
The output of this query in the file is:
One
1
(blank line)
(blank line)
or hex 4F 6E 65 0D 0A 31 0D 0A 0D 0A
The extra line(s) at the bottom are causing problems with steps that use the output as input.
Is there a parameter I can Set at the beginning of the query?
Is it a database option?
I'm not sure there is a way to disable the extra blank lines from the SSMS end of things (I've found "results to file" options/control to be very limited in my experiences). Perhaps use a batch that uses
SQLCMD
to dump to the file, and then use a variation offindstr "." input.txt > output.txt
to strip all blank lines from it before passing to the next step? You may have also have to go further and find a way to remove the line-feed off the last line of text. – Ƭᴇcʜιᴇ007 – 2015-11-18T15:03:38.163I'd like to avoid any extra manipulation of the files because some of them are 1+ GB and growing. But if I have to, findstr better than editing it manually. Thanks – B540Glenn – 2015-11-19T14:25:40.423