Link to home
Start Free TrialLog in
Avatar of Michael Katz
Michael KatzFlag for United States of America

asked on

Cant execute a bcp in sql 2012

My line of code is

Exec xp_cmdshell 'bcp "Select Customer, Invoice from CompanyA.dbo.ArInvoice" queryout "C:\bcptest.txt -S HPELITE\MSSQLSERVER12 " -T -c -t,'

this does not work...

SQLState = S0002, NativeError-208
Error=[Microsoft][SQL Server Native Client 10.0][SQL Server]Invalid object name 'CompanyA.dbo.ArInvoice'.
SQLState=37000. Native Error = 8180
Error=[Microsoft][SQL Server Native Client 10.0][SQL Server]Statement(s) could not be prepared
NULL


Exec xp_cmdshell 'bcp "Select * from sysfiles" query out "C:\bcptext.txt" -T -c -t,' works very well.. exports looks perfect
ASKER CERTIFIED SOLUTION
Avatar of Nakul Vachhrajani
Nakul Vachhrajani
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Invalid object name 'CompanyA.dbo.ArInvoice'.

1) Is the db name "CompanyA" valid?  
2) Does that table name exist in that db?  
3) Does the user running the bcp have access rights to that table?
Avatar of Michael Katz

ASKER

Perfect.. I had my quotes wrong.. stupid mistake.. thank you