Skip to content

Commit

Permalink
Support installation of SQL Express 2019
Browse files Browse the repository at this point in the history
  • Loading branch information
andyundso committed Jul 28, 2024
1 parent c069877 commit 17c3108
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ jobs:
- windows-2022
version:
- 2017
- 2019
exclude:
- force-encryption: "true"
os: ubuntu-24.04
Expand Down
19 changes: 15 additions & 4 deletions install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ param (
[string[]]$Components,
[bool]$ForceEncryption,
[string]$SaPassword,
[ValidateSet("2017")]
[ValidateSet("2017", "2019")]
[string]$Version
)

Expand Down Expand Up @@ -68,7 +68,7 @@ if ("sqlengine" -in $Components) {
# Depends: python (>= 2.7.0) but it is not installable
# Depends: libldap-2.4-2 but it is not installable
# E: Unable to correct problems, you have held broken packages.
if ($IsUbuntu2404) {
if ($IsUbuntu2404 -And $Version -Eq "2017") {
Write-Error "MSSQL 2017 is not available on Ubuntu 24.04."
Write-Error "See more information at https://github.com/microsoft/mssql-docker/issues/868"
exit 1
Expand Down Expand Up @@ -106,14 +106,25 @@ forceencryption = 1
Write-Output "Downloading and installing SQL Server"
New-Item -ItemType Directory -Path "C:\Downloads"

Invoke-WebRequest "https://download.microsoft.com/download/E/F/2/EF23C21D-7860-4F05-88CE-39AA114B014B/SQLEXPR_x64_ENU.exe" -OutFile "C:\Downloads\mssql.exe"
switch ($Version) {
"2017" {
$DownloadUrl = "https://download.microsoft.com/download/E/F/2/EF23C21D-7860-4F05-88CE-39AA114B014B/SQLEXPR_x64_ENU.exe"
$MajorVersion = 14
}
"2019" {
$DownloadUrl = "https://download.microsoft.com/download/7/c/1/7c14e92e-bdcb-4f89-b7cf-93543e7112d1/SQLEXPR_x64_ENU.exe"
$MajorVersion = 15
}
}

Invoke-WebRequest $DownloadUrl -OutFile "C:\Downloads\mssql.exe"
Start-Process -Wait -FilePath "C:\Downloads\mssql.exe" -ArgumentList /qs, /x:"C:\Downloads\setup"
C:\Downloads\setup\setup.exe /q /ACTION=Install /INSTANCENAME=SQLEXPRESS /FEATURES=SQLEngine /UPDATEENABLED=0 /SQLSVCACCOUNT='NT AUTHORITY\System' /SQLSYSADMINACCOUNTS='BUILTIN\ADMINISTRATORS' /TCPENABLED=1 /NPENABLED=0 /IACCEPTSQLSERVERLICENSETERMS

Write-Host "Configuring SQL Express ..."
stop-service MSSQL`$SQLEXPRESS

$InstancePath = "HKLM:\software\microsoft\microsoft sql server\mssql14.SQLEXPRESS\mssqlserver"
$InstancePath = "HKLM:\software\microsoft\microsoft sql server\mssql$MajorVersion.SQLEXPRESS\mssqlserver"
$SuperSocketNetLibPath = "$InstancePath\supersocketnetlib"
set-itemproperty -path "$SuperSocketNetLibPath\tcp\ipall" -name tcpdynamicports -value ''
set-itemproperty -path "$SuperSocketNetLibPath\tcp\ipall" -name tcpport -value 1433
Expand Down

0 comments on commit 17c3108

Please sign in to comment.