Create a batch file to run the sql statement

  • Hi

    I have written stored procedures to create a database with db name as input parameter

    I need to create a batch file to run the stored procedure with input value given in the command prompt along with the batch file will be my dbname, which will be used by the stored procedure to create the databse.

    and also few sql statements to insert data into those tables after creating

    Plz could any one help me out to create code to create a batch file

    thanks in advance

  • Are you asking how to pass a parameter to a batch file, or how to connect to SQL Server from a command prompt? If it's the latter, look up osql in Books Online. If it's the former, this probably isn't the correct forum to be asking the question since it's not strictly to do with SQL Server. Someone on here may still be able to help you, though. Otherwise, Google "pass parameters to batch file" and I think you'll get a lot of hits.

    John

  • You need to do two things...

    1. Click on the Windows {Start} button, click "Help and Support". When the new window appears, enter "BATCH COMMANDS" in the search field, and press the search button. The results will be self evident.

    2. In MS SQL Server Books Online, search the index for OSQL. Read about OSQL and all of the command line parameters that are available.

    --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.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

Viewing 3 posts - 1 through 2 (of 2 total)

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