Forum Discussion
I need to run a large number of individual .sql files quickly
I have a large number of views and indexes that need to be built for our testing environment in a specified order. Up to now, we have just used one long .sql file that had the CREATE statements for the view and indexes. I would like to be able to have separate files for each CREATE statement to make it easier for our developers to use git, but I need to be able to run this build quickly. Is there a way to have a single query or script that can execute the .sql files from a local copy of our git repo. Before I spend time writing something in Powershell to use the sqlcmd utility I wanted to check and see if there was already a tool built into SSMS. Any thoughts or insight on how to do this would be greatly appreciated.
- olafhelperBronze Contributor
bruni-chue wrote: in a specified order.Why in a specific order? The order of index creation doesn't matter in any way.
there was already a tool built into SSMS
Switch SSMS query editor to SqlCmd mode
sqlcmd utility - Edit SQLCMD scripts with Query Editor - SQL Server | Microsoft Learn
and load the .SQL files with ":r" command, see
sqlcmd utility - SQL Server | Microsoft Learn