• RTaylor2208 - Thursday, December 7, 2017 5:06 AM

    One easy and free solution is to use a parameterised batch file (there are more elegant solutions), this is just a basic example.

    Save the following as deploy.bat:
    SET FOLDER=%1
    SET SERVER=%2
    SET DB=%3

    for %%f in (%FOLDER%\*.sql) do sqlcmd -S %SERVER% -d %DB% -E -i %%f > %%f.log

    Then Execute the batch file passing 3 parameters
    deploy.bat C:\temp\Scripts MYSQLServer MySQLDB

    Obviously you can (and should) add additonal logic for error handling, but as a start this will do what you need.

    Nowadays, you can use the "kind of new" FORFILES command to make your life just a little easier.
    https://technet.microsoft.com/en-us/library/cc753551(v=ws.11).aspx

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