MS SQL Server Startup Time
8 Marth 2019 ·

Why would you need to know when MS SQL Server started? Say we’re looking into DBMS waits and want to know how long the sys.dm_os_wait_stats DMV has been collecting data. It keeps its data in RAM from the moment the DBMS starts, just like the other DMVs.

You can get the startup time from sys.dm_os_sys_info:

SELECT sqlserver_start_time FROM sys.dm_os_sys_info

There’s another way, using tempdb. It’s created when the server starts, so its creation time gives us the same answer. You can get it from sys.databases:

SELECT create_date FROM sys.databases WHERE name = 'tempdb'

One catch: the server’s startup time doesn’t necessarily tell you when DMV data collection began. Someone might have cleared the stats by hand, for example like this:

DBCC SQLPERF('sys.dm_os_wait_stats', CLEAR)