Skip to content

Commit

Permalink
Import-BacpacToSqlServer: Fixing that the server and database name pa…
Browse files Browse the repository at this point in the history
…rameters in the connection string parameter were not always used
  • Loading branch information
BenedekFarkas committed Mar 5, 2024
1 parent e9441c5 commit 06a6741
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,17 @@ function Import-BacpacToSqlServer
{
$connectionStringSegments = $ConnectionString.Split(';', [System.StringSplitOptions]::RemoveEmptyEntries)

$serverSegment = $connectionStringSegments | Where-Object { $PSItem.StartsWith('Data Source=') }
$serverSegment = $connectionStringSegments | Where-Object {
$PSItem.StartsWith('Data Source=') -or $PSItem.StartsWith('Server=')
}
if (!([string]::IsNullOrEmpty($serverSegment)))
{
$SqlServerName = $serverSegment.Split('=', [System.StringSplitOptions]::RemoveEmptyEntries)[1]
}

$databaseSegment = $connectionStringSegments | Where-Object { $PSItem.StartsWith('Initial Catalog=') }
$databaseSegment = $connectionStringSegments | Where-Object {
$PSItem.StartsWith('Initial Catalog=') -or $PSItem.StartsWith('Database=')
}
if (!([string]::IsNullOrEmpty($databaseSegment)))
{
$DatabaseName = $databaseSegment.Split('=', [System.StringSplitOptions]::RemoveEmptyEntries)[1]
Expand Down

0 comments on commit 06a6741

Please sign in to comment.