Thursday, December 29, 2011

running multiple scripts in MSSQL

  1. Create the script
  2. :setvar workpath "c:\scripts\"
    :setvar FileToexecute "test3.sql"
    --:r $(workpath)$(FileToexecute)
    :r $(workpath)test1.sql
    :r $(workpath)test2.sql
  3. enable SQLCMD mode
  4. Run the above query

enabling the SQLCMD mode
using :r
joining :r with variables
unable to use buildin sqlcmd variables