October 22, 2009 at 3:35 am
How can I execute a Stored Procedure with parameters through BCP command.
I have the following BCP statement and does not work.
bcp "exec MyDB..Letter_UPDATE @UserName @JobNumber" in "'TEST','123456'" -SMyServer -UMyusername -PMyPassword
Stored Procedure name: Letter_UPDATE
Paramters :@UserName, @JobNumber
Passing Data : "TEST", "123456"
All my other BCP commands are working fine, this is the only SP which has parameters and it is killing me. I hope it is a simple solution.......
Help me......
October 22, 2009 at 4:15 am
It seems to me that you are using wrong direction. You specified in your command line the direction as in. I think that it should be queryout.
Adi
--------------------------------------------------------------
To know how to ask questions and increase the chances of getting asnwers:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
October 22, 2009 at 4:07 pm
Thank you for your reply. However, I tried with queryout and still did not work. Have I used the correct syntax or BCP with SP.....except queryout....
October 22, 2009 at 11:22 pm
You can't use BCP with parameters unless you turn it into dynamic SQL.
--Jeff Moden
Change is inevitable... Change for the better is not.
October 23, 2009 at 3:17 am
I should have paid attention more carefully to the question. It isn’t enough to change the in direction to queryout direction. You also have to specify the parameters’ values in the string. Fallowing your example try to run this BCP:
Bcp “EXEC MyDB..Letter_UPDATE ‘TEST’, ‘123456’” –SmyServer –UmyUserName –PmyPassword.
Adi
--------------------------------------------------------------
To know how to ask questions and increase the chances of getting asnwers:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
October 26, 2009 at 9:59 pm
Hi Adi
Thank you for your assistance, it worked....
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply