Retrieving SQL Server's Last Start Date and Time
Here's a query that returns information about when an instance of SQL Server started.
September 18, 2001
Can I use a system function or extended stored procedure to retrieve the last date and time I started SQL Server?
I'm not aware of a built-in function that returns the last start date and time, although such a function would be a nice addition to the SERVERPROPERTY() function. The Microsoft Windows 2000 Server Resource Kit includes utilities that tell you when a service started. One T-SQL solution is to use xp_cmdshell to run one of the service management utilities that show the time a service started, but a simpler solution exists. Several SQL Server processes connect when you start the server. A row in the master..sysprocesses table represents all SQL Server client connections, including connections that the SQL Server process initiates. The connection with SPID = 1 is always a system connection, and the sysprocesses table includes a column called login_time.
To determine when a particular instance of SQL Server started, you can issue the following query:
SELECT login_time FROM sysprocesses WHERE spid = 1
About the Author
You May Also Like