SQL Server Restart time I am using below command to get SQL Server last restart time :

Select min(Login_time) from master.sys.sysprocesses

select getdate()


Can anyone help me with a query if possible : If the SQL Server last start time is within last 24 Hours from current select getdate() it should be written to another column that SQL Server got restarted last XX hours back along with SQL Server Last restart time.
It's very simple, tempdb database re-creates every time when SQL Server re-started. So, create_date of tempdb database is the date &amp; time when SQL Server restarted/started.

SELECT  case when datediff(mi,create_date,getdate())&lt;1440
        then 'SQL Server got restarted last '+cast(datediff(hh,create_date,getdate()) as varchar)+' hours '+cast(datediff(mi,create_date,getdate())%60 as varchar)+' minutes back. Restart Time is '+Cast(create_date as varchar)
        end
FROM sys.databases where database_id=DB_ID('tempdb')


NOTE: Above query would not return correct result if TF 3609 is enabled in SQL Server

So, in addition to, below query will also help you to find out SQL Serve Start time.

SELECT case when datediff(mi,sqlserver_start_time,getdate())&lt;1440
then 'SQL Server got restarted last '+cast(datediff(hh,sqlserver_start_time,getdate()) as varchar)+' hours '+cast(datediff(mi,sqlserver_start_time,getdate())%60 as varchar)+' minutes back. Restart Time is '+Cast(sqlserver_start_time as varchar)
end
FROM sys.dm_os_sys_info


Thanks