Tuesday, February 7, 2012

SQL Agent Account Through T-SQL

I had recently a weired requirement to get the SQL server AGENT Account from multiple servers, so I'm sharing how to get it through T-SQL

DECLARE @SrvAccount varchar(100)
set @SrvAccount =''
EXECUTE master.dbo.xp_instance_regread
N'HKEY_LOCAL_MACHINE',
N'SYSTEM\CurrentControlSet\Services\SQLSERVERAGENT',
N'ObjectName',
@SrvAccount OUTPUT,
N'no_output'

SELECT @SrvAccount as SQLAgent_ServiceAccount
And the location the registry would be at ... 

SYSTEM\CurrentControlSet\Services\SQLSERVERAGENT



No comments:

Post a Comment