- Repost - originally posted 24-08-2012
SQL PowerShell to the rescue
As part of on going development I was required to run all the database scripts for a new database. This was just less than 300 scripts and it was getting laborious doing it manually. So I delved into the world of SQL PowerShell and found a handy script to automate the running of these scripts.
Sample code: foreach ($f in Get-ChildItem -path "C:\Scripts\" -Filter *.sql | sort-object) { invoke-sqlcmd –ServerInstance "XXX" -Database "YYY" -InputFile $f.fullname -SuppressProviderContextWarning }