RT

解决方案 »

  1.   

    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
      

  2.   

    select login_time from sys.sysprocesses where spid=1
      

  3.   

    --分钟
    select datediff(mi,login_time,getdate()) from sys.sysprocesses where spid=1
      

  4.   

    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'
      

  5.   

    SELECT @@Cpu_Busy + @@Idle As TotalWork
    但返回的TotalWork是Integer型,是毫秒,换算一下就可以了。