Find out how long the sql server service has been running, from t-sql

后端 未结 6 1387
春和景丽
春和景丽 2021-02-07 22:11

I\'d like if its possible to work out from inside sql server how long sql server has been running.

Would like to use this in conjunction with one of the DMV\'s for unuse

6条回答
  •  爱一瞬间的悲伤
    2021-02-07 23:05

    This simple query works for versions before SQL Server 2005 as well as recent ones:

    SELECT
     crdate AS startup,
     DATEDIFF(s, crdate, GETDATE()) / 3600. / 24 AS uptime_days
    FROM master..sysdatabases
    WHERE name = 'tempdb'
    

提交回复
热议问题