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

End of Article




You must log on before posting a comment.

If you don't have a username & password, please register now.

Reader Comments

Conversely, you could query the crdate of tempdb in sysdatabases.

SELECT crdate AS SQLStarted FROM master..sysdatabases WHERE name = 'tempdb'

Mike Armentrout

very fine in short lengh

Anonymous User

Article Rating 5 out of 5