Get Service Account Details of the SQL Agent Service

John picture John · Sep 6, 2011 · Viewed 31.5k times · Source

How can I get the Service Account name for the SQL Agent service for a particular SQL Server (SQL 2005). Is it possible to get using SQL statements or WMI ?

Answer

KyleMit picture KyleMit · May 26, 2015

As Aaron Bertrand pointed out, you can use the undocumented xp_regread in SQL Server 2005 and SQL Server 2008, but there is a better way, starting with SQL Server 2008R2 SP1.

From the article How to identify the SQL Server Service Account in T-SQL, you can use sys.dm_server_services like this:

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;

SQL Service Account Query Results