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

后端 未结 6 1386
春和景丽
春和景丽 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 22:59

    SELECT crdate FROM sysdatabases WHERE [name] = 'tempdb'

    The above will work on SQL Server 2000, 2005 and 2008.

    The logic is that the result from the above SQL returns the created date of the tempdb database, which SQL Server recreates every time it is restarted. Hence, the created date of tempdb is the startup time of the server.

提交回复
热议问题