bcp command isn't working after migration to SQL Server 2012

I have a bat file we've used for years that queries and exports the result to a txt file on another server, however after migrating the database to a new server and upgrading to SQL Server 2012, I can't get it to export and I'm not understanding what it's saying is wrong.

I am putting it into a command prompt to test and it's telling me the copy direction must either be in, out or format and the example shows queryout and that's what I'm using?

E:\>bcp  "select * from SQL01.Voyager.dbo.PosBON" queryout "\\mca008\Accounting\Positive Pay\Positive File\PosPayBON_%timestamp:/=%.txt" -c -T
Copy direction must be either 'in', 'out' or 'format'.
usage: bcp {dbtable | query} {in | out | queryout | format} datafile

I tried removing the queryout and using -o, but that didn't work either, any ideas?

Thanks for your help!
Doris
LVL 4
urthrilledAsked:
Who is Participating?
 
Deepak ChauhanSQL Server DBACommented:
One more simple syntex.

BCP dbo.PosBON in "D:\PosBON.txt" -S SQL01 -d Voyager -T -c
0
 
grendel777Commented:
You're trying to use a trusted connection (-T), but do you (the person logged in) have rights on the SQL server? Can you try it with "-u username -p password" instead?
0
 
urthrilledAuthor Commented:
I removed the -T and added -u -p to the beginning (using the SQL Server sa) and got the same message saying
Copy direction must be either 'in', 'out' or 'format'.
 usage: bcp {dbtable | query} {in | out | queryout | format} datafile
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
Deepak ChauhanSQL Server DBACommented:
What is server name in the select statement you mentioned fourt part name. Try this.

bcp  "select * from Voyager.dbo.PosBON" queryout "\\mca008\Accounting\Positive Pay\Positive File\PosPayBON_%timestamp:/=%.txt" -c -T -S <server name>
0
 
Vitor MontalvãoMSSQL Senior EngineerCommented:
Yes, the ServerName parameter (-S) seems to be missing.
0
 
urthrilledAuthor Commented:
I added -S and the server name, ran it on command prompt and am still getting the same message?  Is there any way the queryout between the query and the filepath needs more, as it seems it is not reading it?

Copy direction must be either 'in', 'out' or 'format'.
  usage: bcp {dbtable | query} {in | out | queryout | format} datafile

Thank you,
Doris
0
 
Deepak ChauhanSQL Server DBACommented:
Let makes it simple

Is it SQL01 is your server name where Voyager data exist ?

bcp  "select * from Voyager.dbo.PosBON" queryout "D:\PosBON.txt" -c -T -S <server name>
0
 
Deepak ChauhanSQL Server DBACommented:
BCP dbo.PosBON out "D:\PosBON.txt"  -S SQL01 -d Voyager -T -c
0
 
Vitor MontalvãoMSSQL Senior EngineerCommented:
Can you post the exact bcp command that you tried last?
0
 
Deepak ChauhanSQL Server DBACommented:
Hi Doris,

Is command working or error still persist?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.