Up time server sql

Configurare noua (How To)

Situatie

Mai jos este o procedura care returneaza de cat timp este up un server de sql. Mai exact, returneaza timpul in minute, ore si zile de cand nu s-a mai dat restart la serverul de sql.

Solutie

alter procedure ServerUpTimeInfo_prc

as

SELECT
(dm_io_virtual_file_stats.sample_ms / 1000.00 ) / 60.00 AS server_up_time_min,
((dm_io_virtual_file_stats.sample_ms / 1000.00 ) / 60.00) / 60.00 AS server_up_time_hr,
(((dm_io_virtual_file_stats.sample_ms / 1000.00 ) / 60.00) / 60.00) / 24.00 AS server_up_time_day

into #temp

FROM sys.dm_io_virtual_file_stats(1,1) AS dm_io_virtual_file_stats

SELECT CAST(server_up_time_min AS decimal(12,2)) AS server_up_time_min,
CAST(server_up_time_hr AS decimal(12,2)) AS server_up_time_hr,
CAST(server_up_time_day AS decimal(12,2)) AS server_up_time_day
FROM #temp

Tip solutie

Permanent
Etichetare:

Voteaza

(7 din 16 persoane apreciaza acest articol)

Despre Autor

Leave A Comment?