December 9, 2002 at 10:10 am
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!!!
December 9, 2002 at 10:22 am
Try
"\t"
December 9, 2002 at 10:40 am
I will. I thought \t was the default statement for tab delimited though?
December 9, 2002 at 11:08 am
I use
/t ","
Far away is close at hand in the images of elsewhere.
Anon.
December 9, 2002 at 11:35 am
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.
December 9, 2002 at 12:21 pm
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!
December 10, 2002 at 2:29 am
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.
December 10, 2002 at 4:05 am
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