Login or Sign Up to become a member!
LessThanDot Site Logo


Community Wiki

Less Than Dot is a community of passionate IT professionals and enthusiasts dedicated to sharing technical knowledge, experience, and assistance. Inside you will find reference materials, interesting technical discussions, and expert tips and commentary. Once you register for an account you will have immediate access to the forums and all past articles and commentaries.

LTD Social Sitings

Lessthandot twitter Lessthandot Linkedin Lessthandot facebook Lessthandot rss

Note: Watch for social icons on posts by your favorite authors to follow their postings on these and other social sites.


Google Ads

Get SQL Server uptime

From Wiki

Jump to: navigation, search

How long has SQL Server been running?

Since tempdb gets recreated every time SQL Server is restarted, it is a good way to figure out how long SQL Server has been up and running. You can use the crdate column in the sysdatabases table to get the creation date of tempdb.

The queries below will give you the time in different formats

  1. SELECT crdate [last startup datetime] FROM master.dbo.sysdatabases
  2. where name = 'tempdb'
  4. SELECT DATEDIFF(hh, crdate, getdate()) AS [Uptime in Hours]
  5. FROM master.dbo.sysdatabases
  6. where name = 'tempdb'
  8. SELECT DATEDIFF(dd, crdate, getdate()) AS [Uptime in Days]
  9. FROM master.dbo.sysdatabases
  10. where name = 'tempdb'
  12. SELECT DATEDIFF(mm, crdate, getdate()) AS [Uptime in Months]
  13. FROM master.dbo.sysdatabases
  14. where name = 'tempdb'

663 Rating: 2.7/5 (36 votes cast)