loading...
AM2.co

Find the SQL Server service account with sys.dm_server_services

amtwo profile image Andy Mallon Originally published at am2.co on ・2 min read

SQL Server 2005 introduced Dynamic Management Views(DMVs). Technically, there are both views & functions–DMVs & DMFs, but colloquially they’re often simply referred to as just “DMVs”. DMVs simply return information about the state of the server or database and can be used for monitoring and troubleshooting of server/database health & performance.

New DMVs are added all the time. Today, let’s take a look at one of those useful DMVs.

This is Callie. She has nothing to do with DMVs, but isn’t she cute?!

sys.dm_server_services

Way back in SQL Server 2008R2 SP1 (Released 2011-07-11), Microsoft introduced the sys.dm_server_services DMV. This is not only an under-appreciated DMV, but one that isn’t all that well-known. Access to this DMV is covered by the VIEW SERVER STATE permission, and Microsoft Docs describe this DMV as:

Returns information about the SQL Server, Full-Text, SQL Server Launchpad service (SQL Server 2017+), and SQL Server Agent services in the current instance of SQL Server. Use this dynamic management view to report status information about these services.

That’s not really the best elevator pitch for the DMV–lets look at the actual data that the DMV includes so that we can better understand it:

SELECT ServiceName = servicename, StartupType = startup\_type\_desc, ServiceStatus = status\_desc, StartupTime = last\_startup\_time, ServiceAccount = service\_account, IsIFIEnabled = instant\_file\_initialization\_enabledFROM sys.dm\_server\_services;

Check out that column list! Not only is the service account listed there, but also the startup time, and whether Instant File Initialization is enabled.

ServiceName StartupType ServiceStatus StartupTime ServiceAccount IsIFIEnabled------------------------------- ----------- ------------- ---------------------------------- -------------------------- ------------SQL Server (MSSQLSERVER) Automatic Running 2020-04-04 10:15:34.3603420 -04:00 NT Service\MSSQLSERVER YSQL Server Agent (MSSQLSERVER) Manual Stopped NULL NT Service\SQLSERVERAGENT N

This DMV was about five years old before I knew it existed. That means I was doing all sorts of unnecessary gymnastics to check the service account, or to check when the instance was created (SELECT create_date FROM sys.databases WHERE name = 'tempdb';). In the years since I learned about sys.dm_server_services, it’s become one of my favorite DMVs.

Is it weird that I have “favorite DMVs”?

The post Find the SQL Server service account with sys.dm_server_services appeared first on Andy M Mallon - AM².

Posted on by:

amtwo profile

Andy Mallon

@amtwo

I am a SQL Server DBA, a Microsoft Data Platform MVP, and a carbaholic. he/him

AM2.co

SQL Server DBA and Microsoft Data Platform MVP managing databases in the healthcare, finance, e-commerce, and non-profit sectors.

Discussion

pic
Editor guide