jaa2013
jaa2013

Reputation: 241

sqlcmd output file remove header and footer

Using SQLCMD, I can output the query result to a text file, now, the text file has header: enter image description here

And footer: enter image description here

How do I remove them during query?

My query, inside a sql file:

SELECT internal_no, item_no, dspl_descr, rtl_prc FROM PLU

My SQLCMD command:

SQLCMD -S SQLSERVER01 -U AdminUser -P au5584 -i C:\text.sql -o C:\out.txt

Upvotes: 10

Views: 19087

Answers (1)

Dbloch
Dbloch

Reputation: 2376

Add

SET NOCOUNT ON

To the top of your query

SET NOCOUNT ON    
SELECT internal_no, item_no, dspl_descr, rtl_prc FROM PLU

And add "-h-1" your SQLCMD command to:

SQLCMD -h-1 -S SQLSERVER01 -U AdminUser -P au5584 -i C:\text.sql -o C:\out.txt

Upvotes: 23

Related Questions