Home Forums Programming Powershell Execute SQLs in Parallel from directory RE: Execute SQLs in Parallel from directory

  • Please find answer below if anyone is looking for it - 

    foreach ($f in Get-ChildItem -path $PSScriptRoot -Filter *.sql | sort-object -desc) {   Start-Job -ScriptBlock { invoke-sqlcmd -InputFile $args[0].fullname -ServerInstance $args[1] } -ArgumentList $f, $ServerName}