Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

BCP Command with Parameters Expand / Collapse
Author
Message
Posted Thursday, October 22, 2009 3:35 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, March 19, 2013 5:46 AM
Points: 9, Visits: 37
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......
Post #807010
Posted Thursday, October 22, 2009 4:15 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Yesterday @ 5:39 AM
Points: 2,104, Visits: 5,378
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/
Post #807020
Posted Thursday, October 22, 2009 4:07 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, March 19, 2013 5:46 AM
Points: 9, Visits: 37
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....
Post #807494
Posted Thursday, October 22, 2009 11:22 PM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: Today @ 5:03 PM
Points: 35,954, Visits: 30,243
You can't use BCP with parameters unless you turn it into dynamic SQL.

--Jeff Moden
"RBAR is pronounced "ree-bar" and is a "Modenism" for "Row-By-Agonizing-Row".

First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column."

"Change is inevitable. Change for the better is not." -- 04 August 2013
(play on words) "Just because you CAN do something in T-SQL, doesn't mean you SHOULDN'T." --22 Aug 2013

Helpful Links:
How to post code problems
How to post performance problems
Post #807612
Posted Friday, October 23, 2009 3:17 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Yesterday @ 5:39 AM
Points: 2,104, Visits: 5,378
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/
Post #807698
Posted Monday, October 26, 2009 9:59 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, March 19, 2013 5:46 AM
Points: 9, Visits: 37
Hi Adi

Thank you for your assistance, it worked....

Post #809074
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse