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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
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
Protecting & Securing Your Critical Data

Considering 93 percent of companies file for bankruptcy within 12 months of a disaster that blocked access to their data for 10 days or more, planning for the worst is just smart business. Learn how Acronis Backup integrates security at every stage

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:
One more simple syntex.

BCP dbo.PosBON in "D:\PosBON.txt" -S SQL01 -d Voyager -T -c
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.