SQL Server Command-Line Installation

This guide provides detailed instructions for installing SQL Server using the command line. This method is particularly useful for unattended installations, scripting, and automation.

Prerequisites: Ensure you have met all system requirements and installed necessary prerequisites before proceeding. Refer to the System Requirements and Prerequisites pages for details.

Overview of Command-Line Installation

The command-line installation process for SQL Server leverages the setup executable (setup.exe) with specific parameters. You can control various aspects of the installation, including instance name, features to install, collation settings, and more.

Steps for Command-Line Installation

1. Prepare Installation Media

Download the SQL Server installation media (ISO file or extracted files) from the official Microsoft website.

2. Open Command Prompt or PowerShell

Launch Command Prompt or PowerShell as an administrator. Right-click on the application icon and select "Run as administrator".

3. Navigate to the Installation Directory

Use the cd command to navigate to the directory where the SQL Server setup files are located. For example:

cd D:\SQLServer2022\x64

4. Run the Setup Command

Execute the setup.exe command with the required parameters. Here's a basic example for installing a default instance with specific features:

setup.exe /ACTION=Install /FEATURES=SQLENGINE,SSMS /INSTANCENAME=MSSQLSERVER /SQLSVCACCOUNT="\" /SQLSVCPASSWORD="" /AGTSVCACCOUNT="\" /AGTSVCPASSWORD="" /IACCEPTSQLSERVERLICENSEAGREEMENTS

Common Installation Parameters

Tip: For a comprehensive list of all available parameters, run setup.exe /? in the command prompt.

Example: Installing a Named Instance

To install a named instance, specify a custom /INSTANCENAME:

setup.exe /ACTION=Install /FEATURES=SQLENGINE /INSTANCENAME=MyNamedInstance /SQLSVCACCOUNT="NT AUTHORITY\Network Service" /IACCEPTSQLSERVERLICENSEAGREEMENTS

Example: Installing with a Configuration File

You can also use a configuration file (ConfigurationFile.ini) for complex installations. First, generate a sample configuration file by running:

setup.exe /PCConfigurationFile="C:\MyConfig\ConfigurationFile.ini"

Then, modify the generated INI file with your desired settings and run the installation using:

setup.exe /ConfigurationFile="C:\MyConfig\ConfigurationFile.ini"

Configuration File Example (ConfigurationFile.ini)

[OPTIONS]
ACTION="Install"
FEATURES=SQLENGINE,CONN,BC,SDK,SSMS
INSTANCENAME="MYNEWINSTANCE"
SQLSVCACCOUNT="NT AUTHORITY\Network Service"
ISSVCSTARTUPTYPE="Automatic"
SQLCOLLATION="SQL_Latin1_General_CP1_CI_AS"
AGTSVCACCOUNT="NT AUTHORITY\Network Service"
AGTSVCSTARTUPTYPE="Automatic"
IACCEPTSQLSERVERLICENSEAGREEMENTS="True"
TCPENABLED="1"
NPENABLED="0"
SQLSVCINSTANCENAME="MYNEWINSTANCE"
AGTSVCINSTANCENAME="MYNEWINSTANCE"
Security Note: Avoid using plain text passwords in scripts or configuration files. Consider using secure methods for managing credentials, such as Windows Authentication or PowerShell secrets management.

Verification

After the installation completes, you can verify it by checking the SQL Server services in the Services snap-in (services.msc) and connecting to the instance using SQL Server Management Studio (SSMS).

Troubleshooting

Setup log files are located in the %ProgramFiles%\Microsoft SQL Server\\\Setup Bootstrap\Log directory. Review these logs for detailed error information.

For silent installations, ensure the IACCEPTSQLSERVERLICENSEAGREEMENTS parameter is set to True.