Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding LocalDB support for 2022 #32

Merged
merged 1 commit into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ jobs:
Pull requests are welcome!

## TODO
* Add LocalDB support for SQL Server 2022.
* MacOS: Migrate docker from qemu to vz to speed up the process.
* Wait for GitHub Actions to support more stuff to make the install sleeker.
* Maybe more tools from [here](https://docs.microsoft.com/en-us/sql/tools/sqlpackage/sqlpackage-download?view=sql-server-ver15).
Expand Down
32 changes: 14 additions & 18 deletions main.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -139,25 +139,21 @@ if ("sqlpackage" -in $Install) {

if ("localdb" -in $Install) {
if ($iswindows) {
if ($Version -eq "2022") {
Write-Output "LocalDB for SQL Server 2022 not available yet."
} else {
Write-Host "Downloading SqlLocalDB"
$ProgressPreference = "SilentlyContinue"
switch ($Version) {
"2019" { $uriMSI = "https://download.microsoft.com/download/7/c/1/7c14e92e-bdcb-4f89-b7cf-93543e7112d1/SqlLocalDB.msi" }
"2022" { $uriMSI = "TBD" }
}
Invoke-WebRequest -Uri $uriMSI -OutFile SqlLocalDB.msi
Write-Host "Installing"
Start-Process -FilePath "SqlLocalDB.msi" -Wait -ArgumentList "/qn", "/norestart", "/l*v SqlLocalDBInstall.log", "IACCEPTSQLLOCALDBLICENSETERMS=YES";
Write-Host "Checking"
sqlcmd -S "(localdb)\MSSQLLocalDB" -Q "SELECT @@VERSION;" -C
sqlcmd -S "(localdb)\MSSQLLocalDB" -Q "ALTER LOGIN [sa] WITH PASSWORD=N'$SaPassword'" -C
sqlcmd -S "(localdb)\MSSQLLocalDB" -Q "ALTER LOGIN [sa] ENABLE" -C

Write-Host "SqlLocalDB $Version installed and accessible at (localdb)\MSSQLLocalDB"
Write-Host "Downloading SqlLocalDB"
$ProgressPreference = "SilentlyContinue"
switch ($Version) {
"2019" { $uriMSI = "https://download.microsoft.com/download/7/c/1/7c14e92e-bdcb-4f89-b7cf-93543e7112d1/SqlLocalDB.msi" }
"2022" { $uriMSI = "https://download.microsoft.com/download/3/8/d/38de7036-2433-4207-8eae-06e247e17b25/SqlLocalDB.msi" }
}
Invoke-WebRequest -Uri $uriMSI -OutFile SqlLocalDB.msi
Write-Host "Installing"
Start-Process -FilePath "SqlLocalDB.msi" -Wait -ArgumentList "/qn", "/norestart", "/l*v SqlLocalDBInstall.log", "IACCEPTSQLLOCALDBLICENSETERMS=YES";
Write-Host "Checking"
sqlcmd -S "(localdb)\MSSQLLocalDB" -Q "SELECT @@VERSION;" -C
sqlcmd -S "(localdb)\MSSQLLocalDB" -Q "ALTER LOGIN [sa] WITH PASSWORD=N'$SaPassword'" -C
sqlcmd -S "(localdb)\MSSQLLocalDB" -Q "ALTER LOGIN [sa] ENABLE" -C

Write-Host "SqlLocalDB $Version installed and accessible at (localdb)\MSSQLLocalDB"
} else {
Write-Output "localdb cannot be installed on mac or linux"
}
Expand Down