The easiest way is to make your scripts stored procedures and call (via the EXECUTE command) each procedure, in turn, from the central procedure. This is ideal if you run the same script (s) (or the same script with different parameters) over and over again.
If your scripts are a .sql file (or any text file), as @Abe Miesller says (upvoted), you can run them from SSMS using the: r command when SQLCMD mode is enabled. You must know and the script the exact path and file name. This cannot be done from a stored procedure.
The last alternative, used with "known" file names and necessary for arbitrary file names (say, for all files loaded into the entire subfolder), is to use the power of the XP_CMDSHELL extended procedure. Such solutions can get compelx pretty quickly (use it to extract a list of files, build and execute through xp_cmdshell a line that calls SQLCMD for each file, in turn, managing results and errors with the help of output files, it goes on and on), so I would just do it as a last resort.
Philip Kelley Mar 08 2018-11-11T00: 00Z
source share