While SQLCMD.exe is the best way, SSMS also has SQLCMD mode where you can execute the SQLCMD script. To enable this mode, click Query in the menu bar, then select SQLCMD Mode .
The ": r filename.sql" command is the SQLCMD script command to import and execute the sql script file. You know that you are in SQLCMD mode, because any lines that are SQLCMD script commands will be displayed with a colored (gray, I think) background.
:setvar path "c:\Path_to_scripts\" :r $(path)\file1.sql :r $(path)\file2.sql
NYSystemsAnalyst May 08 '09 at 17:04 2009-05-08 17:04
source share