SQLCMD returns --- column header

  • Hi folks,

    I need to add code to an existing dos batch file that will return one single row of data.

    SQLCMD -E -d MyDBName -oMyDay.txt -Q "SET NOCOUNT ON SELECT SUBSTRING(Datename(dw, Max(BUSINESSDATE)),1,3) from MyDBName.dbo.Sales"

    This returns :

    ----

    Fri

    How do I NOT return the '----' ???

    Thanks in Advance !

    john

  • Look up sqlcmd in Books Online.

    The command line argument you're loking for is "-h" the value you should supply is -1.

    ML

    ---
    Matija Lah, SQL Server MVP
    http://milambda.blogspot.com

  • Easy solution, thank you.

    I did not know I could pass -1 and the documentation clearly states: Use -1 to specify that headers must not be printed.

  • Those darn manuals. They know everyting!

    ML

    ---
    Matija Lah, SQL Server MVP
    http://milambda.blogspot.com

  • Is there any way to keep header text, without the '-----------' line upon generation? Other than reopen the file and purge that line.

  • type C:\Scripts\Option2.txt | findstr /v \-\- > C:\Scripts\DestFile.csv

    del C:\Scripts\Option2.txt

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply