Controls the registration of an instance of Microsoft SQL Server in the Microsoft Windows Active Directory. The actions of sp_ActiveDirectory_SCP always apply to the connected instance of SQL Server.
sp_ActiveDirectory_SCP [ @Action = ] N'action'
[ @Action = ] N'action'
Specifies whether the Active Directory object registering the instance of SQL Server is to be created, updated, or deleted. action is nvarchar(20) with a default of N'create'.
Registers the instance of SQL Server in the Active Directory by creating an MS-SQL-SQLServer object in the directory. The MS-SQL-SQLServer object records the attributes of the instance of SQL Server at the time the action is performed. If you specify this value and the instance is already registered, the object is updated.
Refreshes the attributes registered for the current instance of SQL Server in the Active Directory. Updates the attributes recorded in the MS-SQL-SQLServer object in the Active Directory.
Removes the Active Directory registration for the current instance of SQL Server. Deletes the MS-SQL_SQLServer object from the Active Directory. Also removes the registrations of any databases and publications in the instance.
Return Code Values
0 (success) or 1 (failure)
After registering an instance of SQL Server in the Active Directory, you can use sp_ActiveDirectory_Obj to register any of the databases in the instance, and you can use sp_addpublication or sp_addmergepublication to register publications.
Active Directory registration can only be modified by the account that created it. When you change the security account used by the SQL Server service, delete the Active Directory registration, change the service account, and then create the Active Directory registration again.
Requires membership in the sysadmin fixed server role.
The following example registers the current instance of SQL Server in the Active Directory.
DECLARE @RetCode INT EXEC @RetCode = sp_ActiveDirectory_SCP @Action = N'create' PRINT 'Return code = ' + CAST(@RetCode AS VARCHAR)