Why do we need this information?
This is an important piece of information for a SQL Server engineer. I carefully tend to use the word “engineer” here because this information helps all kinds of people who works with SQL Server. As an Administrator would like to understand when did it happen to understand the underlining issue with any server level issues/fail over details etc. As a performance Engineer, this information helps when the cache gets cleared and for many other reasons. So its very important and useful information as long as you are working in SQL Server.
Now, there are two different ways your SQL Service could get restart – (1) By restarting the SQL Service and (2) By restarting the Windows Server. Let us look at different ways to find this information.
What are the different ways to get last restart of SQL Service?
Method 1: Using sys.dm_os_sys_info
Its the most simple, easiest and my favorite way to get this information.
SELECT sqlserver_start_time FROM sys.dm_os_sys_info
Method 2: Using tempdb database creation date
SELECT create_date FROM sys.databases WHERE name = 'tempdb'
Method 3: Using sp_readerrorlog
sp_readerrorlog 0,1,'Copyright (c)'
What are the different ways to get last restart of Windows Server?
Method 1: Using Task Manager
Up time represents how long the server is being up and running since the last restart. So to calculate when did the reboot happened, need to substract the up time with current date and time.
Method 2: Using systeminfo command
systeminfo | find /i "Boot Time"
Hope this helps and if you have any other ways, please share in the comment section.
I’d like to grow my readership. If you enjoyed this blog post, please share it with your friends!
Like this:
Like Loading...
Related