Skip to content

Instantly share code, notes, and snippets.

@bymyslf
Created January 25, 2017 14:18
Show Gist options
  • Select an option

  • Save bymyslf/b79d1dd2d33979cf2c697f19f38370ca to your computer and use it in GitHub Desktop.

Select an option

Save bymyslf/b79d1dd2d33979cf2c697f19f38370ca to your computer and use it in GitHub Desktop.
Run SQL Scripts via PowerShell and SqlCmd utility
param
(
[String]$Path,
[String]$Server,
[String]$Database
)
$sqlCmdUtil = "C:\Program Files\Microsoft SQL Server\110\Tools\Binn\SQLCMD.EXE"
Get-ChildItem $Path\*.sql | Sort-Object -Property Name | % { & $sqlCmdUtil -S $Server -d $Database -i $_.FullName -t 750 -l 600 }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment