0

I've got a directory with a bunch of SQL files ( queries ) that I'd like to execute. What's the best way to go about it?
I can do it static but that seems a little inefficient if other files are added.

invoke-sqlcmd -inputfile "c:\temp\adduserl.sql" -serverinstance "10.129.221.91" -database "GoodOne" -username "user" -password "pw1"

invoke-sqlcmd -inputfile "c:\temp\addaddressesl.sql" -serverinstance "10.129.221.91" -database "GoodOne" -username "user" -password "pw1"

Perhaps a for loop of some sorts?

jarlh
  • 42,561
  • 8
  • 45
  • 63
Kyuzo
  • 21
  • 1
  • 8
  • 1
    Does this answer your question? [Loop through files in a directory using PowerShell](https://stackoverflow.com/questions/18847145/loop-through-files-in-a-directory-using-powershell) – CaptainTrunky Jan 04 '23 at 13:09
  • @CaptainTrunky thank you, it did indeed put me in the right direction, now trying to figure out some other errors ;). – Kyuzo Jan 04 '23 at 14:09

0 Answers0