Sql Server - how to get last server restart (DMV reset date/time)

Go To StackoverFlow.com

8

I'm using some modifications to Glenn Berry's excellent DMV queries!

However, I would like to add to the resultset the 'last server restart', or to be more specific, the date/time the statistics for (all, the specific) DMV was reset.

Since it would be quite important to know last reset when looking at the statistics, I want to make absolutely sure the date/time is accurate and shown.

Question: How can you get the most accurate date/time of when a/all DMV statistic was reset?

Thanks! -D

2012-04-05 15:27
by dhartford
Sometimes need to be better about knowing the correct key-words to search for, duplicate of: http://stackoverflow.com/questions/1036824/find-out-how-long-the-sql-server-service-has-been-running-from-t-sq - dhartford 2012-04-16 15:01


7

Using a prior question (different key words), I ended up using this approach. As always, up to the individual what would be 'best' for them!

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

source: Find out how long the sql server service has been running, from t-sql

2012-04-16 15:02
by dhartford


10

SELECT sqlserver_start_time FROM sys.dm_os_sys_info
2012-07-11 22:13
by user1318325
This will only work from SQL Server 2008 - user1318325 2012-12-20 19:53


2

This will work but you have to know the service name also its only available with R2 and later

SELECT last_startup_time 
FROM   sys.dm_server_services 
WHERE  servicename = "Your Service name" 

Although this won't be totally accurate since you can also reset the DB specific views via a DB detach or a DB close.

Also there are two views that can be reset on a live db sys.dm_os_latch_stats and sys.dm_os_wait_stats

2012-04-05 15:44
by Conrad Frix


0

There are many ways to check when was SQL server restarted last time.

Below mentioned SQL queries can be used to quickly find out the server restart date time.

 SELECT sqlserver_start_time FROM sys.dm_os_sys_info;  



SELECT login_time FROM sys.dm_exec_sessions WHERE session_id = 1;  



 select start_time from sys.traces where is_default = 1  ;



 SELECT crdate FROM sysdatabases WHERE name='tempdb'  ;



 SELECT create_date FROM sys.databases WHERE name = 'tempdb' ;
2017-05-17 10:04
by Kundan Dasange
Ads