Determine service accounts for SQL Server, Agent through TSQL


DECLARE @sqlServiceaccountName sysname
EXECUTE master.dbo.xp_instance_regread
N’HKEY_LOCAL_MACHINE’,
N’SYSTEM\CurrentControlSet\Services\MSSQLSERVER’,
N’ObjectName’,
@sqlServiceAccountName OUTPUT,
N’no_output’
SELECT @sqlServiceaccountName

DECLARE @agentServiceaccountName sysname
EXECUTE master.dbo.xp_instance_regread
N’HKEY_LOCAL_MACHINE’,
N’SYSTEM\CurrentControlSet\Services\SQLSERVERAGENT’,
N’ObjectName’,
@agentServiceAccountName OUTPUT,
N’no_output’
SELECT @agentServiceaccountName

Advertisements