How can I download and install SQL 2019 smoothly?

142    Asked by debbieJha in SQL Server , Asked on May 27, 2024

I am a database administrator at a particular company planning to upgrade its database management system from server 2014 to SQL server 2019. My task is to ensure a smooth transition by first downloading and then Installing the process of SQL 2019 on a test environment. 

Answered by Dadhija raj

 In the context of SQL, you can easily download and install the SQL server 2019 for a test environment by using these steps:-

Firstly, you would need to go to the SQL server 2019 to download official page. You can download it from its official Website. There you would need to select the appropriate version or edition of it and click on the download link.

Now you have downloaded the SQL server 2019. Now you can Install it. Before installing the process you would need to select the installation type:-

Basic- This would install with the default settings.

Custom- It would allow you to choose the features and specify the installation's path.

Download media- You can download the installation files for offline Installation under this section.

Custom installation

Feature selection

You can choose the component which you wan.

Instance Configuration

Default instance of named Instance.

Server configuration

You can specify the SQL server service account

Post installation

SQL server management studio (SSMS)

You can download and also install the SSMS to manage your SQL server instance.

Update SQL server

You can check for the latest cumulative updates and then apply them.

Here is the example given in java programming language:-

Import java.io.BufferedReader;
Import java.io.InputStreamReader;
Import java.net.URL;
Import java.nio.file.Files;
Import java.nio.file.Paths;
Public class SQLServerInstaller {
    Public static void main(String[] args) {
        Try {
            // Define the URLs for SQL Server 2019 and SSMS downloads
            String sqlDownloadUrl = https://go.microsoft.com/fwlink/?linkid=866658;
            String ssmsDownloadUrl = https://aka.ms/ssmsfullsetup;
            String sqlDownloadPath = “SQLServer2019-SSEI-Expr.exe”;
            String ssmsDownloadPath = “SSMS-Setup-ENU.exe”;
            // Download SQL Server 2019 installer
            System.out.println(“Downloading SQL Server 2019…”);
            downloadFile(sqlDownloadUrl, sqlDownloadPath);
            System.out.println(“Downloaded to “ + sqlDownloadPath);
            // Define the command for basic installation
            String installCommand = sqlDownloadPath + “ /qs /x:SQL2019 /ACTION=Install /FEATURES=SQL,Tools /INSTANCENAME=MSSQLSERVER /SECURITYMODE=SQL /SAPWD=YourStrong!Passw0rd /SQLSYSADMINACCOUNTS=”” + System.getProperty(“user.name”) + “””;
            // Run the installation command
            System.out.println(“Installing SQL Server 2019…”);
            runCommand(installCommand);
            System.out.println(“SQL Server 2019 installation completed.”);
            // Download SSMS
            System.out.println(“Downloading SQL Server Management Studio (SSMS)…”);
            downloadFile(ssmsDownloadUrl, ssmsDownloadPath);
            System.out.println(“Downloaded to “ + ssmsDownloadPath);
            // Install SSMS
            String ssmsInstallCommand = ssmsDownloadPath + “ /install /quiet”;
            System.out.println(“Installing SQL Server Management Studio (SSMS)…”);
            runCommand(ssmsInstallCommand);
            System.out.println(“SSMS installation completed.”);
            // Post-installation: Check for updates
            System.out.println(“Checking for SQL Server updates…”);
            String updateCommand = “powershell -Command ”(New-Object Net.WebClient).DownloadString(‘https://docs.microsoft.com/en-us/sql/sql-server/install/sql-server-update-center?view=sql-server-ver15’)””;
            runCommand(updateCommand);
            System.out.println(“SQL Server update check completed.”);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    Private static void downloadFile(String fileUrl, String destinationPath) throws Exception {
        Try (BufferedInputStream in = new BufferedInputStream(new URL(fileUrl).openStream())) {
            Files.copy(in, Paths.get(destinationPath));
        }
    }
    Private static void runCommand(String command) throws Exception {
        Process process = Runtime.getRuntime().exec(command);
        Try (BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()))) {
            String line;
            While ((line = reader.readLine()) != null) {
                System.out.println(line);
            }
        }
        Int exitCode = process.waitFor();
        If (exitCode != 0) {
            Throw new RuntimeException(“Command execution failed with exit code: “ + exitCode);
        }
    }
}

Here is the example given in python programming language:-

Import os
Import subprocess
Import urllib.request
# Define the URL for SQL Server 2019 download
Download_url = https://go.microsoft.com/fwlink/?linkid=866658
Download_path = “SQLServer2019-SSEI-Expr.exe”
# Download the SQL Server 2019 installer
Print(“Downloading SQL Server 2019…”)
Urllib.request.urlretrieve(download_url, download_path)
Print(f”Downloaded to {download_path}”)
# Define the command for basic installation
Install_command = f”{download_path} /qs /x:SQL2019 /ACTION=Install /FEATURES=SQL,Tools /INSTANCENAME=MSSQLSERVER /SECURITYMODE=SQL /SAPWD=YourStrong!Passw0rd /SQLSYSADMINACCOUNTS=”{os.getlogin()}””
# Run the installation command
Print(“Installing SQL Server 2019…”)
Subprocess.run(install_command, shell=True)
Print(“SQL Server 2019 installation completed.”)
# Download SQL Server Management Studio (SSMS)
Ssms_download_url = https://aka.ms/ssmsfullsetup
Ssms_download_path = “SSMS-Setup-ENU.exe”
Print(“Downloading SQL Server Management Studio (SSMS)…”)
Urllib.request.urlretrieve(ssms_download_url, ssms_download_path)
Print(f”Downloaded to {ssms_download_path}”)
# Install SSMS
Ssms_install_command = f”{ssms_download_path} /install /quiet”
Print(“Installing SQL Server Management Studio (SSMS)…”)
Subprocess.run(ssms_install_command, shell=True)
Print(“SSMS installation completed.”)
# Post-installation: Check for updates
Print(“Checking for SQL Server updates…”)
Update_command = “powershell -Command ”(New-Object Net.WebClient).DownloadString(‘https://docs.microsoft.com/en-us/sql/sql-server/install/sql-server-update-center?view=sql-server-ver15’)””
Subprocess.run(update_command, shell=True)
Print(“SQL Server update check completed.”)


Your Answer

Interviews

Parent Categories