locked
Run Stored Procedure through Batch Files [CMD] RRS feed

  • Question

  • Hi,

    I want to execute my SP through Batch Files on CMD.

    Can somebody help me on this ?

    Wednesday, November 14, 2012 6:53 AM

Answers

    • Proposed as answer by Tom Phillips Wednesday, November 14, 2012 9:45 PM
    • Marked as answer by Kalman Toth Tuesday, November 20, 2012 7:27 AM
    Wednesday, November 14, 2012 6:58 AM
  • Hello,

    You can use the command line tool "sqlcmd Utility" from your batch file to connect to a sql server and execute a SQL Statement / stored procedure.


    Olaf Helper

    Blog Xing

    • Marked as answer by Kalman Toth Tuesday, November 20, 2012 7:27 AM
    Wednesday, November 14, 2012 6:59 AM
  • you can use SQLCMD to run store procedure from CMD.

    SQLCMD -S ServerName -U USerName -P Passoword -d DBName -Q "Exec SP_Name"

    you can do like this.

    Refer Link : http://msdn.microsoft.com/en-us/library/ms170207(v=sql.105).aspx 


    Regards,
    Rohit Garg
    (My Blog)
    This posting is provided with no warranties and confers no rights.
    Please remember to click Mark as Answer and Vote as Helpful on posts that help you. This can be beneficial to other community members reading the thread.

    • Marked as answer by Kalman Toth Tuesday, November 20, 2012 7:27 AM
    Wednesday, November 14, 2012 12:05 PM

All replies

    • Proposed as answer by Tom Phillips Wednesday, November 14, 2012 9:45 PM
    • Marked as answer by Kalman Toth Tuesday, November 20, 2012 7:27 AM
    Wednesday, November 14, 2012 6:58 AM
  • Hello,

    You can use the command line tool "sqlcmd Utility" from your batch file to connect to a sql server and execute a SQL Statement / stored procedure.


    Olaf Helper

    Blog Xing

    • Marked as answer by Kalman Toth Tuesday, November 20, 2012 7:27 AM
    Wednesday, November 14, 2012 6:59 AM
  • you can use SQLCMD to run store procedure from CMD.

    SQLCMD -S ServerName -U USerName -P Passoword -d DBName -Q "Exec SP_Name"

    you can do like this.

    Refer Link : http://msdn.microsoft.com/en-us/library/ms170207(v=sql.105).aspx 


    Regards,
    Rohit Garg
    (My Blog)
    This posting is provided with no warranties and confers no rights.
    Please remember to click Mark as Answer and Vote as Helpful on posts that help you. This can be beneficial to other community members reading the thread.

    • Marked as answer by Kalman Toth Tuesday, November 20, 2012 7:27 AM
    Wednesday, November 14, 2012 12:05 PM
  • Please explain how to pass parameters in the call.

    sqlcmd .... -Q "Execute <stored proc name> <param1> <param2> <etc..>"

    Saturday, December 28, 2013 12:25 AM