Search

Saturday, January 7, 2012

How to programmatically find out when the SQL Server service started?

Everytime SQL Server starts, it recreates the tempdb database. So, the creation date and time of the tempdb database tells us the date and time at which SQL Server service started. This information is stored in the crdate column of the sysdatabases table in master database. Here's the query to find that out:
SELECT crdate AS 'SQL Server service started approximately at:'
FROM master.dbo.sysdatabases WHERE name = 'tempdb'


SQL Server error log also has this information (This is more accurate) and the error log can be queried using xp_readerrorlog

1 comment:

  1. http://www.business-world-online.com is the world’s most popular website for buying or selling a business. We work with business brokers as well as thousands of private sellers to give you the largest selection of businesses for sale on the web

    ReplyDelete