A way to execute multiple .sql files at once in SQL Server

I have about 100 .sql files that create stored procs. I would like to fulfill them right away.

They are contained inside a folder with a name Stored Procedures. There Stored Proceduresare several other folders with different names in the folder - table names.

Is there a way to execute all of these files at once?

+3
source share
3 answers

Here is another Sql_Server_Script_Executor tool

Is there a way to execute all of these files at once?

* You can add a folder and all your files will appear in the list. Click "Run" and finish !!!!!!!!!!!!!! *

It contains three transaction modes.

1. Execute scripts within one transaction
2. Execute scripts on separate transaction
3. No transaction

and many other functions, please go through it.

enter image description here

+2
source

PowerShell , :

Get-ChildItem ".\Stored Procedures\*.sql" | ForEach-Object { sqlcmd -S ServerName -d DatabaseName -E -i $_.FullName }

.sql sqlcmd.exe. sqlcmd, sqlcmd /?.

, -Recurse Get-ChildItem -Filter:

Get-ChildItem '.\Stored Procedures' -Filter *.sql -Recurse | ForEach-Object { sqlcmd -S ServerName -d DatabaseName -E -i $_.FullName }
+3

Not right away, but all in one go - try a tool like SSW Deploy .

enter image description here

+1
source

All Articles