February 8, 2010 at 8:05 pm
Hi,
I am just wondering if there is way to figure out when SQL Server was last restarted using TSQL?
Thanks.
February 8, 2010 at 8:10 pm
There are a bunch of system processes that are started when SQL Server starts. The time that these processes start is effectively the time that SQL Server started.
With the above explanation, the following gives you your answer
select MIN(login_time) from sys.sysprocesses
February 10, 2010 at 8:21 am
Another way is to check when the tempdb is created..
PS: Tempdb is recreated whenever the server is started..
select create_Date from sys.databases
where name = 'tempdb'
One more point, Tempdb is created before the services start, hence we will get a earlier time .
Kindest Regards,
Paarthasarathy
Microsoft Certified Technology Specialist
http://paarthasarathyk.blogspot.com
February 11, 2010 at 12:01 am
A few days ago there was a nice article about this subject
http://www.sqlservercentral.com/scripts/GETDATE()/69319/
Regards,
Marco
December 23, 2012 at 5:53 am
If your SQL Server is 2005 or later, you can use:
SELECT 'Statistics since: ' + CAST(sqlserver_start_time AS VARCHAR) FROM sys.dm_os_sys_info
It's more safe and reliable.
January 21, 2013 at 5:49 am
fdassis (12/23/2012)
If your SQL Server is 2005 or later, you can use:SELECT 'Statistics since: ' + CAST(sqlserver_start_time AS VARCHAR) FROM sys.dm_os_sys_info
It's more safe and reliable.
Not so much a case of reliability than accuracy. The first entry is start up (in dm_os_sys_info). This is followed by system process starting followed by tempdb creation.
SELECT 'OS Info - SQL Start' AS Process, sqlserver_start_time AS Time FROM sys.dm_os_sys_info
UNION ALL
SELECT 'System Process Start', MIN(login_time) FROM sys.sysprocesses
UNION ALL
SELECT 'TempDB Created', create_date FROM sys.databases WHERE name = 'tempdb'
April 23, 2015 at 10:59 am
Starts in 2008, not 2005. dm_os_sys_info.sqlserver_start_date started only in 2008.
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply