How to Find the Last Time SQL Server was Started
In this Article, let’s take a look at different ways we can check the date and time SQL Server was started last time. There are multiple ways to do it and each of them has its pros and cons.
Using TempDB
The first method we shall look is to see when was the TempDB created. If you recollect, one of the first things you have learned about TempDB is that it is a database used to store objects temporarily and is refreshed/ recreated every time SQL Server is started. Here we would use the creation time of TempDB to determine when was the SQL Server started last time. To do this, open SQL Server Management Studio, go to object explorer, expand databases node/folder. Expand System databases and right-click on Tempdb as shown below and choose properties.
http://learnsqlwithbru.com/wp-content/uploads/2011/09/Start_Time_TempDB1.png
Database properties window of Tempdb is displayed. In the very first screen when the General page is selected you can notice the Date Created column (highlighted below)…
http://learnsqlwithbru.com/wp-content/uploads/2011/09/Start_Time_TempDB2.png
This way of finding information from Tempdb creation is the easiest way I feel. This step is
SQL Server Error Log
Another way of finding the same information is from the SQL Server Error Logs. This is also one of the easier ways of finding the SQL Server start time, but can be tricky sometimes, which I shall explain in a while..
First let’s take a look at the steps to perform this task. In object explorer, expand the Management node and find SQL Server Logs. Right click on SQL Server Logs and go to View –> SQL Server Log (as shown below). These SQL Server Logs contain very important information regarding that SQL Server. Every time SQL Server is started, entries are written in the SQL Server Log.
http://learnsqlwithbru.com/wp-content/uploads/2011/09/Start_Time_SQL_Error_Log1.png
When the entries in Error Log are displayed, you can scroll down to the row which contains the SQL Startup information. In the picture below, look at the entry at 8/27/2011 7:48:06 PM.
http://learnsqlwithbru.com/wp-content/uploads/2011/09/Start_Time_SQL_Error_Log2.png
It looks like you could find the startup information in SQL Error Log easily, but in some cases it might not be that way. Every time a database backup is performed, there is an entry in the SQL Server Error Log which on an SQL Instance with multiple databases will result in a large number of entries and it would make it difficult to find this information easily. Also, in some cases the Error Log would be regularly recycled in order to ensure that it is easier to read the Error Log and once the maximum number of Error Logs are reached, SQL Server disposes the oldest Error Log when it has to create a new one.
Windows event Logs
The next method to find the SQL Server start time is finding it through the Windows Event log viewer. Explaining the details of how to open a event log viewer (with pictures) is beyond the scope of this blog. So let me give tell you in short steps. Right-click your computer and choose manage. Under System Tools, expand Event Viewer, choose Windows Logs. Once you are in Windows Logs, choose Application. The main section of the console displays the events from various applications installed on your server. A SQL Server startup information is displayed as a shown below. The main problem of finding the SQL Server startup information this way is difficult, since you have to go through th list of events.. Since I am aware of the startup time, I could go straight to that date and time in the application log.
http://learnsqlwithbru.com/wp-content/uploads/2011/09/Start_Time_Event_Log2.png
sys.dm_os_sys_info Dynamic Management View
This is another way and the most easiest way to find the SQL Server start time and date. The information is readily available by querying the dynamic management view sys.dm_os_sys_info. The column name is **sqlserver_start_time. **This dmv has been there since SQL Server 2005, but the column sqlserver_start_time is added starting from SQL Server 2008.
http://learnsqlwithbru.com/wp-content/uploads/2011/09/Start_Time_DMV.png
Summarizing the blog, looking at the Tempdb create time is an option you can choose no matter what SQL Server version you are using. In case of SQL Server 2008 or above, querying the dmv mentioned above is the easiest way to go…
-- Bru Medishetty