I have just created a proxy and I need to grant access to the proxy to the account that runs the sql server agent. It will probably be a domain account.
How can I find it using T-SQL?
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It only takes a minute to sign up.Sign up to join this community
In SQL Server 2005 and SQL Server 2008 there was no documented way. So undocumented command
xp_regread was used to get the result
DECLARE @sn NVARCHAR(128); EXEC master.dbo.xp_regread 'HKEY_LOCAL_MACHINE', 'SYSTEM\CurrentControlSet\services\SQLSERVERAGENT', 'ObjectName', @sn OUTPUT; SELECT @sn;
Since SQL Server 2008R2 SP1 we have a documented way to get to this information:
You can use below query to find the same:
SELECT DSS.servicename, DSS.startup_type_desc, DSS.status_desc, DSS.last_startup_time, DSS.service_account, DSS.is_clustered, DSS.cluster_nodename, DSS.filename, DSS.startup_type, DSS.status, DSS.process_id FROM sys.dm_server_services AS DSS;