Execute SP through DOS

69510 pts.
Tags:
DOS Batch
SQL Server
SQL Server 2005
Can you tell me how to execute the parametrized procedure using DOS or command prompt?

Software/Hardware used:
Sql Server 2005 and DOS

Answer Wiki

Thanks. We'll let you know when a new response is added.
sqlcmd -E -S %1 -d %2 -Q "EXEC schema.spname %3 %4

%1 corresponds to server_name
%2 corresponds to database_name
%3 corresponds to param1
%4 corresponds to param2
...

Discuss This Question: 4  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • TomLiotta
    Can you explain a little more what you need to do? The question has both AS/400 Parameters and SQL Server tags. Those are very different environments, and "DOS" isn't exactly closely related to either, though SQL Server has some reasonable connection. What process are you expecting to run? That is, can you describe an actual usage? Tom
    125,585 pointsBadges:
    report
  • DOSBATCH
    I want to execute parametrized procedure through batch file ex C:spexec.cmd sp_test1 40,Ray,2011-05-11 spexec.cmd is a batch file and sp_test1 is procedure name 40,Ray,date are parameter of procedure. Pls help me on this.
    30 pointsBadges:
    report
  • carlosdl
    DOSBATCH, if you really want to get useful answers, you will have to provide more details. Please answer these questions: Does this have something to do with an AS/400 environment ? What operating systems are involved ? Is sp_test1 an SQL Server stored procedure ? What does spexec.cmd exactly do ? Also, if you have tried something, please let us know what you tried and the results you got.
    69,510 pointsBadges:
    report
  • Chui54
    Here's a correction to the above: sqlcmd -E -S %1 -d %2 -Q "EXEC schema.%3 %4 %5 %6" %1 corresponds to server_name %2 corresponds to database_name %3 corresponds to sp_name %4 corresponds to param1 %5 corresponds to param2 %6 corresponds to param3
    135 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following