Monday, May 12, 2014

Identify the SQL Server Service Accounts using tSQL.

Every so often you are going to need to check the SQL Server service accounts.  Maybe you've just taken on a new customer, or you've inherited someone else's SQL inventory, and you don't know what accounts the services are running under.  You can remote into the servers one at a time, and run SQL Server Configuration Manager, but --  that is kind of time consuming.  Use this piece for a much quicker way to find your service accounts.  You can even run it across a CMS (Central Management Server) Group, and collect this data from all of your servers with one execution.

    SELECT  
         ds.servicename [ServiceName],
         ds.startup_type_desc [StartupType],
         ds.status_desc [ServiceStatus],
         ds.service_account [ServiceAccount],
         ds.filename [EXEFileName],
         ds.last_startup_time [LastStartup]
    FROM
         sys.dm_server_services ds;


There are some other values from sys.dm_server_services as well, but I've just returned a few quick details on the service accounts.  See this for more details on this DMV:

    http://technet.microsoft.com/en-us/library/hh204542.aspx

No comments:

Post a Comment