Create Table #errorlog (LogDate datetime,ProcessInfo varchar(max),Text nvarchar(max)) INSERT Into #errorlog Exec Master..xp_readerrorlog SELECT LogDate FROM #errorlog WHERE Text Like '%SQL Server is Starting%' DROP Table #errorlog
select login_time from sys.sysprocesses where spid=1
--分钟 select datediff(mi,login_time,getdate()) from sys.sysprocesses where spid=1
SELECT crdate time_restart,GETDATE() AS time_now, DATEDIFF(mi,crdate,GETDATE()) AS minutes_since_restart, @@cpu_busy/15000.0 AS minutes_cpu_busy, @@io_busy/15000.0 AS minutes_io_busy, @@idle/15000.0 AS minutes_idle, (@@cpu_busy+@@io_busy+@@idle)/15000.0 AS minutes_since_restart2, @@connections AS connections FROM master..sysdatabases WHERE name = 'tempdb'
SELECT @@Cpu_Busy + @@Idle As TotalWork 但返回的TotalWork是Integer型,是毫秒,换算一下就可以了。
INSERT Into #errorlog Exec Master..xp_readerrorlog
SELECT LogDate FROM #errorlog WHERE Text Like '%SQL Server is Starting%'
DROP Table #errorlog
select datediff(mi,login_time,getdate()) from sys.sysprocesses where spid=1
DATEDIFF(mi,crdate,GETDATE()) AS minutes_since_restart,
@@cpu_busy/15000.0 AS minutes_cpu_busy,
@@io_busy/15000.0 AS minutes_io_busy,
@@idle/15000.0 AS minutes_idle,
(@@cpu_busy+@@io_busy+@@idle)/15000.0 AS minutes_since_restart2,
@@connections AS connections
FROM master..sysdatabases
WHERE name = 'tempdb'
但返回的TotalWork是Integer型,是毫秒,换算一下就可以了。