Adding & Removing SQL Features via Command

sqldba.blogMore of my SQL Server writing is at sqldba.blog, including the current take on installs and patch levels: the builds and lifecycle reference.

To add a feature to an existing SQL Server instance from the command line, run setup.exe from the installation media with /ACTION=Install, the feature name and the name of the instance you already have. To take one away, use /ACTION=Uninstall with the same two values. There is no separate AddFeatures or RemoveFeatures action. Run a discovery before and after, so you have a record of what changed.

The example below adds and then removes Replication on a default instance:
1. Checking Features Installed on a SQL Server
2. Installing a SQL Server Feature (Replication)
3. Uninstalling a SQL Server Feature (Replication)


1. Checking Features Installed on a SQL Server

Before installing or removing features, it’s essential to know which features are already installed on your SQL Server instance.

Prerequisite: Mounted SQL Server ISO
Mount the installation media for the same major version as the instance before you start, and open the command prompt as Administrator. Setup needs administrator rights for every action in this post, discovery included.

Running the Discovery Command
To check the installed features, run the following command from the root of the media to perform a “Discovery” of the SQL Server instance. It scans the machine and writes a report of every SQL Server feature it finds, without changing anything.

Code
Setup.exe /q /ACTION=RunDiscovery
SQL Server Run Discovery via Command

Viewing the Discovery Results
Once the discovery completes, open the Summary.txt file in C:\Program Files\Microsoft SQL Server\<version>\Setup Bootstrap\Log, where the version folder is 170 for SQL Server 2025, 160 for 2022 and 150 for 2019. Each run also gets its own date-stamped folder there, with an HTML copy of the report. More ways to read the installed features, including T-SQL and the registry, are in How to Check Features Installed in SQL Server.

SQL Server RunDiscovery Summary File

2. Installing a SQL Server Feature (Replication)

Now that you know how to check for existing features, let’s move on to adding a new feature. In this example, we will install the Replication feature.

Installing the Replication Feature
To install the Replication feature via the command line, use the following syntax:

PowerShell
.\Setup.exe /qs /ACTION=Install /FEATURES=Replication /INSTANCENAME=MSSQLSERVER /IACCEPTSQLSERVERLICENSETERMS
SQL Server Install Feature via Command

Here’s a breakdown of the parameters:
/qs : Shows progress but takes no input. Microsoft only supports /qs with the Install action; use /q for no window at all.
/ACTION=Install : Installs the feature. Pointed at an instance that already exists, it adds to that instance instead of creating a new one.
/FEATURES=Replication : The feature to add. Separate several with commas, for example /FEATURES=Replication,FullText.
/INSTANCENAME=MSSQLSERVER : The existing instance. MSSQLSERVER is the default instance; for a named instance use its name, such as SQLEXPRESS.
/IACCEPTSQLSERVERLICENSETERMS : Required whenever setup runs with /q or /qs.

Verifying the Installation
After running the installation command, you can verify the feature installation by performing another Discovery.

SQL Server RunDiscovery Summary File Replication

Feature Names That Changed in SQL Server 2022 and 2025

The values for /FEATURES have moved on since this post was first written in 2019. Microsoft’s Install SQL Server from the command prompt page holds the full list. The common ones still work on 2025: SQLEngine, Replication, FullText, PolyBase, AdvancedAnalytics, AS and IS. These have gone from setup:

  • RS: Reporting Services left the SQL Server installer after 2016. It is a separate download, and from SQL Server 2025 on-premises reporting is Power BI Report Server.
  • Tools, BC, Conn, SDK, SNAC_SDK and the Distributed Replay features DREPLAY_CTLR and DREPLAY_CLT: SQL Server 2019 and earlier only. SSMS has its own installer.
  • SQL_INST_MR and SQL_INST_MPY (the R and Python runtimes) apply to 2017 and 2019, and SQL_INST_JAVA and PolyBaseJava to 2019 only.
  • DQ (Data Quality Services) and MDS (Master Data Services): discontinued in SQL Server 2025. They are still in 2022.

On my SQL Server 2025 lab instance the discovery report lists AI Services and Language Extensions next to the Database Engine, and SERVERPROPERTY('IsAdvancedAnalyticsInstalled') returns 1 there. Check the report rather than assuming a feature name from an older version.


3. Uninstalling a SQL Server Feature (Replication)

If you decide to remove a feature that is no longer needed, the process is just as straightforward as installation.

Uninstalling the Replication Feature
To uninstall the Replication feature from your SQL Server instance, use the following command:

PowerShell
Setup.exe /q /ACTION=Uninstall /FEATURES=Replication /INSTANCENAME=MSSQLSERVER
SQL Server Uninstall Feature via Command

Uninstall doesn’t need the licence switch. Be careful with the feature list here: /FEATURES=SQLEngine on an uninstall removes the Database Engine and every feature that depends on it, such as Replication and Full-Text Search. If the engine is all the instance holds, the instance goes with it. If that is what you are after, DBA Scripts: Uninstall SQL Server on sqldba.blog covers removing a whole instance.

Verifying the Uninstallation
Once uninstallation is complete, run the Discovery command once more to verify that Replication has been removed.

SQL Server RunDiscovery via Command Removing Feature

We can check the Summary.txt file to confirm that the Replication feature is no longer listed.

Microsoft’s reference for every switch is Install SQL Server from the command prompt, and the step-by-step for the setup wizard is Add features to an instance of SQL Server. Read both before making changes on a production server.

The Media and Patch Level Trap

The part of this job that catches people is not the command, it is the media. Adding a feature needs setup media for the same major version as the instance, so keep the ISO for every version you run somewhere findable. On my SQL Server 2025 lab instance a copy of setup is cached under C:\Program Files\Microsoft SQL Server\170\Setup Bootstrap\SQL2025, which is handy for a discovery when the ISO isn’t to hand, but Microsoft’s add-features procedure starts from the installation media.

The second half of the trap is patch level. Your instance is likely patched to a recent Cumulative Update, but the ISO is RTM. A feature added from RTM media is installed at RTM level, and Microsoft warns that the mix can cause unexpected behaviour or errors until you bring the new feature up to the same level. So the real procedure is three steps, not one: add the feature, re-run the current CU, then verify. The documented /UpdateSource parameter can pull the CU in during the install itself if you point it at a folder holding the update package. My current patching workflow, including the verification queries, is on sqldba.blog in DBA Scripts: SQL Server Installation and Patching.

Silent Mode Hides the Errors

With /q there is no window to show you a failure, and a failed run can look exactly like a successful one from the prompt. Two habits keep this honest. First, run the console elevated, because setup needs administrator rights. Second, treat Summary.txt as the verdict. The top of the file gives you the outcome. This one is from a CU install on my SQL Server 2025 lab instance:

Code
Overall summary:
  Final result:                  Passed but reboot required, see logs for details
  Exit code (Decimal):           3010
  Requested action:              Patch

Passed with exit code 0 is a clean result. Exit code 3010 means it worked but wants a restart, so plan one before you call the change done. Anything else means the change did not land, and the Detail.txt file in the same date-stamped folder holds the actual reason. Check it before running the command a second time, because re-running a partially failed setup without knowing why it failed tends to make the log harder to read, not the problem go away.

After Replication Is Installed, and Before It Is Removed

Installing the Replication feature only lays down binaries. There is still no distributor, no publications and no agents until you configure them, so do not expect anything in SSMS to look different beyond the feature being available. Once replication is configured and running, the health checks for agent state and latency are on sqldba.blog in DBA Scripts: Get Replication Status.

Removal deserves the same respect in reverse. If the instance is acting as a publisher or distributor, tear the replication configuration down first, dropping publications and disabling distribution, before uninstalling the feature. Removing binaries out from under a live topology leaves orphaned metadata on the other servers involved. And as with the install, confirm the removal in Summary.txt rather than trusting a silent prompt, then run one final discovery so the report on file matches reality.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *