Export of data without Headers

  • I'm having a brain freeze day, how can I export data from a SQL 2000 table without having the column headings on the .TXT file?

    Is BCP the answer or can it be done in T-SQL.

    Thanks ahead of time for any help.

  • I'm using 2005 but I'm pretty sure the same applies to 2000 if my memory serves me well.

    Click on "Query" on you menu bar and there should be a Query options section and under the section where you choose how you want your results I.E grid text file etc I'm pretty sure you can say no headers

    ----------------------------------------------
    Try to learn something about everything and everything about something. - Thomas Henry Huxley

    :w00t:
    Posting Best Practices[/url]
    Numbers / Tally Tables[/url]

    SQL-4-Life
  • This worked great, I found the options, any idea how to set them in a SQL proc?

  • have you tried using the osql command in .BAT file?

    I'm suer hwo you going to be running your proc.

    If you can run it from a .BAT file or a dos prompt then it may help:

    http://www.di-mgt.com.au/osqlUtility.htm

    ----------------------------------------------
    Try to learn something about everything and everything about something. - Thomas Henry Huxley

    :w00t:
    Posting Best Practices[/url]
    Numbers / Tally Tables[/url]

    SQL-4-Life
  • As Christoper suggests, you may want to create the report (in T-SQL, possible as a sproc) and have OSQL run it... to suppress the headers, use the -h-1 parameter in the call to OSQL.  If you're allowed to use xp_CmdShell, you can call OSQL from the T-SQL using a trusted connection.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • And, yes... BCP will also create output without headers.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • It looks like the only way to do this with osql is to do the following:

    osql -E -d pubs -q "select * from dbo.authors" >junk.txt -h-1

     

    then I write a VB script to delete the last line because it has the format (23 rows affected)

     

    If there are any other suggestions, let me know; I'll also try the BCP option.

  • No, no... just add SET NOCOUNT ON...

    osql -E -d pubs -q "SET NOCOUNT ON select * from dbo.authors" >junk.txt -h-1

    You could also do it in a file using the -i parameter and you could also execute a stored proc.  But, the SET NOCOUNT ON thing will eliminate the need of that VB script...

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • thanks so much 

Viewing 9 posts - 1 through 8 (of 8 total)

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