I am trying to use BCP and failing at the first hurdle. I am running this on SQL Server 2008 SP2
Taking Nigel Rivett's most basic example from his simple talk article at http://www.simple-talk.com/sql/database-administration/creating-csv-files-using-bcp-and-stored-procedures/
BCP master..sysobjects out c:\sysobjects.txt -c -t, -T –S[ServerName]
(with [ServerName] replaced by the name of my server, double checked from the value of @@servername )
I just get:
I get the same error in SSMS in SQL Cmd mode as well as using sqlcmd and it makes no difference if I enclose the table and output file in double quotes.
I have tried it with several other tables and options to no avail. For instance, if I use a query in quotes
Any ideas anyone?
Regards, Nigel Ainscoe
asked Jan 07, 2010 at 07:10 PM in Default
bcp is a command line tool. You should not execute it from inside sqlcmd or SSMS. If you have to, invoke a OS shell using xp_cmdshell.
answered Jan 07, 2010 at 07:15 PM
BCP is not a SQL statement, it's a command line application. You can't run it directly in a SQL batch but you can shell out to it via xp_cmdshell. If you take a closer look at Nigel's article, he shows how to do this.
answered Jan 07, 2010 at 07:26 PM