Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find out how long the sql server service has been running, from t-sql

I'd like if its possible to work out from inside sql server how long sql server has been running.

Would like to use this in conjunction with one of the DMV's for unused indexes, but the counters are re-set every time sql server loads, so I'd like to know how useful they're going to be.

like image 766
Nick Kavadias Avatar asked Jun 24 '09 07:06

Nick Kavadias


People also ask

How do you check how long SQL Server has been running?

This is the exact time: SELECT sqlserver_start_time FROM sys. dm_os_sys_info. The value tends to be slightly earlier than the sys. dm_exec_sessions method.

How can I tell if SQL Server is running on a remote computer?

In the SQL Server Configuration Manager, from the left pane select SQL Server Services. Now, some services will appear in the right pane. Now, each service in the right pane will have some icon. If the service have green triangle icon then, it means the service is running.


1 Answers

I know this is super old, but Microsoft has added a new DMV with this information since this question was asked.

SELECT dosi.sqlserver_start_time
FROM sys.dm_os_sys_info AS dosi
like image 188
SQLing4ever Avatar answered Oct 23 '22 17:10

SQLing4ever