SQL Server Last Start Date

There are multiple ways of finding out when was the last time SQL Server restarted. There are a couple of dynamic management views and DBCC command that you can use to get this information.

Using tempdb created date. SQL Server clear up the tempdb when it starts. Here is what stated in the Windows event log during SQL Server start up, 'Clearing tempdb database', then 'Starting up database 'tempdb' '.

Find the tempdb create date in sys.databases,

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

From SQL Server 2008 forward, sqlserver_start_time is added to sys.dm_os_sys_info DMV.

SELECT sqlserver_start_time
FROM sys.dm_os_sys_info

There is also an undocumented DBCC command, DBCC DBINFO


Find the line with field dbi_crdate. The value would be the created date. Why use unsupported and undocumented way if you have reliable method? This DBCC provide some good information for other purpose.

No comments:

Post a Comment