SQLTreeo Compare · How-to

Find configuration drift across all your SQL Servers

Compare sp_configure settings, trace flags, logins, Agent and database options of one reference SQL Server with all your other instances, in one matrix.

SQLTreeo Compare compares one reference SQL Server with all your other instances in a single run and shows in one matrix where each of them drifted from your standard: cost threshold for parallelism, max degree of parallelism, max server memory, the logins that should exist, the recovery model of the databases.

This article shows the steps in SQLTreeo Compare and in a pipeline. Further down is the way to do part of it by hand.

With SQLTreeo Compare

  1. On the start page, choose Compare several environments at once and click Server configuration.
  2. Name the baseline, for example Production or Standard, and click Choose… to pick the reference instance. No database is needed.
  3. Add the other servers: rename the suggested environments, click Add environment for more, and pick the instance of each one.
  4. Press Compare.

Server configuration matrix with differences in sp_configure values, a login and server roles per server

Every server is compared with the baseline. The matrix lists every setting and object that differs on at least one server: sp_configure values, trace flags, logins, server roles and permissions, credentials, linked servers, endpoints, database options and files, SQL Server Agent jobs, alerts and operators, Database Mail, Resource Governor and Extended Events sessions. In this example the Test server still has the default cost threshold and parallelism, less memory, a database in another recovery model and an extra sysadmin login.

  • Click a tile to see only what differs on that server.
  • Click a cell to open the comparison of the reference server with that server, with the item selected. From there Script… writes the configuration script that applies the reference settings to that server.
  • Use Comparison options before you compare to ignore what differs on purpose, such as hardware, file system paths, the product version or database file sizes.

In a pipeline

Add --server to compare server configuration instead of database schemas:

sqlcompare environments --server -b "Server=sql-prod01;Integrated Security=true" -e "Acceptance=Server=sql-acc01;Integrated Security=true" -e "Test=Server=sql-test01;Integrated Security=true" --ignore-hardware --ignore-paths --format html --output estate.html

The exit code is 0 when every server matches the reference, 1 when one differs and 2 when one could not be read. Run it every night and you know the next morning when a server drifted.

By hand

In SQL Server Management Studio, register your servers under a group in Registered Servers (or a Central Management Server), right-click the group and choose New Query. A query in that window runs on every server of the group and adds a Server Name column:

SELECT name, value, value_in_use
FROM sys.configurations
WHERE name IN ('cost threshold for parallelism', 'max degree of parallelism',
               'max server memory (MB)', 'optimize for ad hoc workloads')
ORDER BY name;

Copy the result into a spreadsheet and pivot it with the setting names as rows and the servers as columns, and the differences stand out.

That works for one view at a time. Logins and server roles, trace flags, database options, SQL Server Agent, Database Mail and Resource Governor each need their own query and their own pivot.

Good to know

  • Comparing several servers needs SQLTreeo Compare 0.1.9 or later.
  • Comparing and looking at the differences are free. Exporting a report, the command line and copying, saving or running a script work during the 30-day trial or with a license, see Trial and licensing.
  • A section that one server does not have, such as SQL Server Agent on Azure SQL Database, gives a warning when you open the comparison of that server, and the items the other server has in it show as missing or extra. Compare like platforms, or leave those types out. The matrix report of the command line does not list these warnings.
  • To compare two instances in detail, see Compare the configuration of two SQL Server instances.