March 11, 2010 at 3:21 pm
I am trying to run the following and I get the usage error. Please help.
Declare @FileName varchar(50)
DECLARE @BCPCommand varchar(7000)
set @FileName = Replace('cds_returns'+convert(varchar(10),getdate(),101)+'.csv','/','')
SET @BCPCommand = 'bcp "select receiver_name as Name
,BankAccountID as Account
,amount as Amount
, tr as CheckingSavings
, 063192874 as RT
from postcard.dbo.ach_info" queryout "c:\test\' + @FileName + '" -c -T -S "POSTPRODDR.POSTCARD"'
exec master.dbo.xp_cmdshell @BCPCommand
March 11, 2010 at 3:43 pm
The output what I get is
usage: bcp {dbtable | query} {in | out | queryout | format} datafile
[-m maxerrors] [-f formatfile] [-e errfile]
[-F firstrow] [-L lastrow] [-b batchsize]
[-n native type] [-c character type] [-w wide character type]
[-N keep non-text native] [-V file format version] [-q quoted identifier]
[-C code page specifier] [-t field terminator] [-r row terminator]
[-i inputfile] [-o outfile] [-a packetsize]
[-S server name] [-U username] [-P password]
[-T trusted connection] [-v version] [-R regional enable]
[-k keep null values] [-E keep identity values]
[-h "load hints"]
NULL
March 11, 2010 at 9:33 pm
First error I see is that you have the database name in the -S parameter. Remove the .POSTCARD and try again.
--Jeff Moden
Change is inevitable... Change for the better is not.
March 12, 2010 at 8:07 am
Yes, you are right. Database name does not need to be there. I added S option only when it was not working.
The real reason for it not working was strange. Between RT and from there was no space but only new line so I did not notice that there is no space. When I was running just the query, it was running fine. But apparantly the space was needed when running the bcp command. As soon as I put space between RT and from, it worked. Thanks to all.
Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply