April 24, 2015 by Mike Hillwig
My company has a rule. We must reboot each of our Windows servers at least quarterly in order to ensure they have the latest patches. Finding out how long a Windows server has been up has long driven us nuts. However, SQL Server does know how long the instance has been up.
What is one of the things that SQL Server does when it starts? It recreates tempdb! That means if we can determine when tempdb was created, we know when SQL Server started.
SELECT crdate [INSTANCE START TIME] FROM master.dbo.sysdatabases WHERE NAME='tempdb'
This works in my environment because we have business rules in place that say when we stop a SQL instance, we reboot the server. Additionally, all of my instances are standalone (non-clustered) SQL instances.