How to know the start time of SQL Server?

One of my friends asked me “How do I find out when the SQL Server is started/restarted?”

Well. There can be many ways to know this. The two methods I know are querying the system views sysdatabases and dm_os_sys_info

Method 1 : Query sysdatabases


select
	crdate
from
	master..sysdatabases
where
	name='tempdb'

The result is

crdate
-----------------------
2017-09-01 15:58:28.417

Method 2 : Query dm_os_sys_info

select
	sqlserver_start_time
from
	sys.dm_os_sys_info

The result is


sqlserver_start_time
-----------------------
2017-09-01 15:58:12.613

Note : This shows the time that my SQL server instance is started. You will get different time

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s