Blog Post

Last restart of SQL Server

,

Occasionally I need to see what the date of last restart of SQL Server. The old method isto check the creation date of tempdb database. However, in SQL 2008 we have a DMV that can be used for this purpose: sys.dm_os_sys_info. Here's how:

 

1) Searching creation of tempdb

SELECT
    d.create_date,
    DAY(GETDATE()) - DAY(d.create_date) DaysUpTime
FROM sys.databases d
WHERE d.name like 'tempdb'

2) Using the DMV sys.dm_os_sys_info
select
    i.sqlserver_start_time,
    DAY(GETDATE()) - DAY(i.sqlserver_start_time) DaysUpTime
from sys.dm_os_sys_info i;

Rate

You rated this post out of 5. Change rating

Share

Share

Rate

You rated this post out of 5. Change rating