When working with multiple database instances in SQL Server, managing registered servers or a central management server can greatly assist with day-to-day operations. Here are the three key differences between registered servers and central management servers:
Registered Servers:
1. Connection data storage: Connection data is stored locally in an XML file, with passwords being encrypted.
2. Authentication options: Registered servers can be used with both SQL Server Authentication and Windows Authentication.
3. Applicability: Registered servers can be utilized for the database engine, SSAS (SQL Server Analysis Services), SSIS (SQL Server Integration Services), and SSRS (SQL Server Reporting Services).
Central Management Servers:
1. Connection data storage: Connection data is stored in a central SQL Server, specifically in the msdb database.
2. Authentication options: Central management servers can only be used with Windows Authentication.
3. Applicability: Central management servers are primarily used for the database engine.
It’s worth noting that the central management server (CMS) serves as a subgroup within registered servers, as indicated in the provided example. The query shared allows you to retrieve server details from the msdb database when querying a CMS instance.
dvgfv tb.

1. Script to Retrieve Registered Server Details:
This script retrieves information about registered servers, including the parent group, group name, display name, server name, and description.
“`sql
SELECT
CASE
WHEN parent_id = 0 THEN ‘NONE’
ELSE (SELECT name FROM msdb.dbo.sysmanagement_shared_server_groups WHERE server_group_id = Grps.parent_id)
END AS [Parent Group],
Grps.name AS [Group Name],
Srv.name AS [Display Name],
Srv.server_name AS [Server Name],
Srv.[description]
FROM msdb.dbo.sysmanagement_shared_registered_servers AS Srv
LEFT OUTER JOIN msdb.dbo.sysmanagement_shared_server_groups AS Grps ON Srv.server_group_id = Grps.server_group_id;
“`
2. Script to Add a Registered Server:
This script demonstrates how to add a new registered server, specifying the server name, connection details, and authentication method.
“`sql
EXEC msdb.dbo.sp_add_server_internal
@server_name = ‘MyRegisteredServer’,
@server_type = ‘SQL Server’,
@server_local = ‘False’,
@is_registered = ‘True’,
@use_local = ‘False’,
@parent_id = 1, — ID of the server group
@srvproduct = ‘SQL Server’,
@providername = ‘SQLNCLI11’,
@datasource = ‘MyServerInstance’,
@location = ‘MyServerLocation’,
@providerstring = ‘SQLNCLI11:Server=MyServerInstance;Integrated Security=SSPI’,
@catalog = ‘MyDatabase’;
“`
3. Script to Create a Central Management Server:
This script demonstrates how to create a central management server (CMS), specifying the server name, connection details, and authentication method.
“`sql
EXEC msdb.dbo.sp_sysmanagement_create_shared_server_internal
@server_name = ‘MyCentralManagementServer’,
@server_type = ‘SQL Server’,
@is_registered = ‘True’,
@use_local = ‘False’,
@providername = ‘SQLNCLI11’,
@datasource = ‘MyServerInstance’,
@location = ‘MyServerLocation’,
@providerstring = ‘SQLNCLI11:Server=MyServerInstance;Integrated Security=SSPI’,
@catalog = ‘msdb’;
“`
These scripts provide a starting point for managing registered servers and central management servers in SQL Server. Remember to adjust the server names, connection details, and other parameters according to your specific environment.
Feel free to explore these features and functionalities further. Happy exploring


