Question

I have the following SQL which works fine on my instance of SQL Server (2012), I have tested this on two client machines who are also both running this version and they receive the error below

Mine

   DECLARE @FileName varchar(50),
   @bcpCommand varchar(8000)

   SET @bcpCommand  = 'bcp northwind.dbo.customers out c:\Temp\Testing.xls -T -r\n -c -t\t'
   PRINT @bcpCommand
   EXEC master..xp_cmdshell @bcpCommand 

Error Copy direction must be either 'in', 'out' or 'format'.

Difference The only difference between mine and the client is that instead of a trusted connection -T, I specify the username and password

  SET @bcpCommand  = 'bcp Production.dbo.Cashbook out C:\Temp\Testing.xls -usa -ppassword -r\n -c -t\t -s@@SERVERNAME'
Was it helpful?

Solution

I would try changing the case of the -u to -U and of the -p to -P. I was reading that it is case sensitive.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top