SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


bcp error: Copy direction must be either 'in', 'out' or 'format'


bcp error: Copy direction must be either 'in', 'out' or 'format'

Author
Message
alejandrovargas1
alejandrovargas1
Forum Newbie
Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)

Group: General Forum Members
Points: 9 Visits: 1
Good evening, i need your help please,Im tryng to modify and ExecuteProcess Task in a DTS in order to export a portion of a table and not the whole one.

Initially read some parameters in an activex script and then passes to a batch file by means of en excuteprocess task:

the original batch file content is this:
bcp %1 out %2 -c -t"|" -Straficosql -T -- works ok

i tried to modify its content as this:

bcp "select * from %1 where %3 >= %4 and %3 <= %5" queryout %2 -c -t"|" -Straficosql -T
i run the above batch file yielding an error:Copy direction must be either 'in', 'out' or 'format'
the output is this:

C:\WINDOWS>bcp select * from TRAFICO1.dbo.HECHOS_TRAFICO_DATOS_PREPAGO_201308_5338_5347 queryout \\trafico\Historicos_Tablas\PLANOS_TRAFICO\HECHOS_TRAFICO_DATOSPREPAGO_201308_5338_5347.txt -c -t"|" -Strafico\traficosql -T
Copy direction must be either 'in', 'out' or 'format'.
usage: bcp {dbtable | query} {in | out | queryout | format} datafile

dont know if its a syntax error or because of double quotes between select statements
Thanks for your help in advanced
Luis Cazares
Luis Cazares
SSC-Forever
SSC-Forever (41K reputation)SSC-Forever (41K reputation)SSC-Forever (41K reputation)SSC-Forever (41K reputation)SSC-Forever (41K reputation)SSC-Forever (41K reputation)SSC-Forever (41K reputation)SSC-Forever (41K reputation)

Group: General Forum Members
Points: 41746 Visits: 19815
Put the query and file between double quotes and it should work.
bcp "select * from TRAFICO1.dbo.HECHOS_TRAFICO_DATOS_PREPAGO_201308_5338_5347" queryout "\\trafico\Historicos_Tablas\PLANOS_TRAFICO\HECHOS_TRAFICO_DATOSPREPAGO_201308_5338_5347.txt" -c -t"|" -Strafico\traficosql -T



Luis C.
General Disclaimer:
Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?


How to post data/code on a forum to get the best help: Option 1 / Option 2
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search