-
Notifications
You must be signed in to change notification settings - Fork 0
/
Demo1.ps1
30 lines (21 loc) · 868 Bytes
/
Demo1.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
Clear-Host
$SqlServerName = 'localhost'
$DatabaseName = 'MsBip'
$Path = 'e:\MsBip\Release\'
###################################################
$InputFile = [system.io.fileinfo](Join-Path $Path 'sql2.txt')
$FileName = $InputFile.BaseName
Write-Host "Deploying: $FileName"
# prevent 'bug' in Invoke-Sqlcmd to set location to SQLSERVER
# should no longer exist in sql 2016
$location = Get-Location
$output = Invoke-Sqlcmd `
-ServerInstance $SqlServerName `
-Database $DatabaseName `
-InputFile $InputFile.FullName `
-OutputSqlErrors $true `
-ErrorAction Stop `
Set-Location -Path $location
Write-Host "Display output from query:"
$output
# https://docs.microsoft.com/en-us/powershell/module/sqlserver/invoke-sqlcmd?view=sqlserver-ps