snippetsqlModerate
How to determine Windows Server start time using T-SQL
Viewed 0 times
howsqltimeusingwindowsstartserverdetermine
Problem
I am looking for a way to find out when the Windows Server was last started using only t-sql commands.
I am trying to stay within the default security configurations (i.e. I don't want to enable xp_cmdshell)
I am trying to stay within the default security configurations (i.e. I don't want to enable xp_cmdshell)
Solution
You can use the
Will get you this information.
ms_ticks column from sys.dm_os_sys_info. This is the number of milliseconds since the computer was started.SELECT DATEADD(SECOND, (ms_ticks/1000)*(-1), GETDATE())
FROM sys.dm_os_sys_infoWill get you this information.
Code Snippets
SELECT DATEADD(SECOND, (ms_ticks/1000)*(-1), GETDATE())
FROM sys.dm_os_sys_infoContext
StackExchange Database Administrators Q#47356, answer score: 10
Revisions (0)
No revisions yet.