June 24, 2016 at 12:26 pm
i know of a couple of ways to get a good handle on when the SQL service was restarted; there's a method with xp_readerror log, but i like to use either of a couple of DMV's for the when the Service was last started.
--sqlserver_start_time
--2016-03-29 08:34:07.890
--create_date
--2016-03-29 08:34:13.087
SELECT sqlserver_start_time from sys.dm_os_sys_info i;
select create_date from sys.databases where name='tempdb';
but what about the Server itself? i poked around the dmv's and don't see anything to show that, for example , the server last rebooted in January, but the SQL service was restarted a month ago.
do i have to do bigint math on ticks from dm_os_sys_info ?
Lowell
June 24, 2016 at 12:59 pm
answering my own question, by converting ms_ticks to seconds, i think i see what i was after:
--ServerRestartTimeServiceRestartTimeServiceUpTimeInDays
2015-08-22 21:46:51.9802016-03-29 08:34:07.89087
-- select
DATEADD(second, -1 * ( ms_ticks / 1000),getdate()) as ServerRestartTime,
i.sqlserver_start_time As ServiceRestartTime,
DATEDIFF(dd,i.sqlserver_start_time,GETDATE()) AS ServiceUpTimeInDays
from sys.dm_os_sys_info i;
Lowell
September 30, 2024 at 7:48 pm
This was removed by the editor as SPAM
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply