bcp queryout with delimiters

  • I'm trying to bcp a query to a comma delimited text file. I can't seem to get the -t field term option on bcp to work for a comma delimited output file. I have tried

    -t \,

    -t\,

    -t,

    -t ,

    -t"\,"

    -t "\,"

    can someone please help with the correct syntax?? Thanks!!!

  • Try

    "\t"

  • I will. I thought \t was the default statement for tab delimited though?

  • I use

    /t ","

    Far away is close at hand in the images of elsewhere.
    Anon.

  • quote:


    I will. I thought \t was the default statement for tab delimited though?


    My bad. See DavidBurrows' reply. I'm thinking tab delimited since that what I usually use.

  • I use

    /t ","

    I just tried :

    -t ","

    -t","

    /t","

    \t","

    and none of those seemed to do it. It keeps saying 'incorrect syntax near queryout'. My entire statement is:

    set @sql = 'bcp "select * from georgia_invoices_copy..daily_invoices order by invid" queryout \\chicagofs\ameritech\sbc\test_out.txt /t ","'

    ...where I have tried all of the above listed delimiters in place of the /t ","

    Thanks for your help!

  • Are you exec'ing the SQL. You will need to

    exec master.dbo.xp_cmdshell @sql.

    And you will need /c parameter as well.

    Far away is close at hand in the images of elsewhere.
    Anon.

  • Also you will need to define you connection user account and password or use /T for trusted connection.

    Try this

    set @sql = 'master..xp_cmdshell ''bcp "select * from georgia_invoices_copy..daily_invoices order by invid" queryout \\chicagofs\ameritech\sbc\test_out.txt /c /t "," /T'' '

    Just a note - and / are both considered standard command line switches and bcp recognizes both.

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

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