Find the SQL Server service account with sys.dm_server_services
Tags: sql, sqlserver, database, tsql
Published: 2020-05-18 13:41:37

---
title: Find the SQL Server service account with sys.dm_server_services
published: true
date: 2020-05-12 13:00:56 UTC
tags: sql, sqlserver, database, TSQL
canonical_url: https://am2.co/2020/05/find-the-sql-server-service-account-with-sys-dm_server_services/?utm_source=rss&utm_medium=rss&utm_campaign=find-the-sql-server-service-account-with-sys-dm_server_services
---

SQL Server 2005 introduced [Dynamic Management Views(DMVs)](https://docs.microsoft.com/en-us/sql/relational-databases/system-dynamic-management-views/system-dynamic-management-views). 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.

[![](http://am2.co/wp-content/uploads/HappyCallie-225x300.jpg)](https://www.youtube.com/watch?v=oxYiYApx_F8)<figcaption id="caption-attachment-3012">This is <a href="https://twitter.com/CalliePie" rel="noopener noreferrer" target="_blank">Callie</a>. She has nothing to do with DMVs, but isn’t she cute?!</figcaption>

## 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](https://docs.microsoft.com/en-us/sql/relational-databases/system-dynamic-management-views/sys-dm-server-services-transact-sql) 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](https://am2.co/2015/06/how-to-find-the-sql-server-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](https://am2.co/2020/05/find-the-sql-server-service-account-with-sys-dm_server_services/) appeared first on [Andy M Mallon - AM²](https://am2.co).