To Call a stored procedure(SQL server) from a batch file on DOS prompt

  • Hi,

    Good evening to All.

    I have a query regarding execution of a batch file from DOS prompt.

    I have a batch file as follows.

    @ECHO off

    cls

    :start

    goto CONNECT

    :CONNECT

    sqlcmd -S IP address,port -U username -P password -q "query"

    goto END

    :END

    I am able to get the answer when I am running the batch file but not able to get out of sqlcmd prompt automatically. If I am giving quit command manually. I am getting out.

    Please let me know how to QUIT command in the batch file.

    Thanks,

    Venu.

  • sqlcmd -S IP address,port -U username -P password -Q "query"

    Notice the captial "Q" - this will run the command and quit.

  • Hi ,

    Thanks for the response .capital 'Q' worked for me.

    Thanks,

    Venu.

  • HI,

    Can you give me an example how to run a batch of sql statements(not stored procedure..),using a batch file?

    Thanks,

    venu

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply