I need to create a .cmd file to execute the sql files in a order

  • Hi Can you please suggest me how to create an .cmd file to execute the Sql modules in a order

    Thanks!!!!

  • If you want to use the command prompt and execute sql statements use SQLCMD

    Sanz
  • You can create a batch file and list down all the sql script files in the batch file which you want to execute in the desired order and execute the batch file.

    Something like this

    SQLCMD servername DbName -E -Script1.sql

    SQLCMD servername DbName -E -Script2.sql

    SQLCMD servername DbName -E -Script3.sql

    and so on...

    Please check for the exact syntax for the SQLCMD.

    --------------------------------------------------------------------------------------------------
    I am just an another naive wannabe DBA trying to learn SQL Server

  • Thanks!!!!

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

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