HiveBrain v1.2.0
Get Started
← Back to all entries
snippetsqlModerate

How to determine Windows Server start time using T-SQL

Submitted by: @import:stackexchange-dba··
0
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)

Solution

You can use the 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_info


Will get you this information.

Code Snippets

SELECT DATEADD(SECOND, (ms_ticks/1000)*(-1), GETDATE())
    FROM sys.dm_os_sys_info

Context

StackExchange Database Administrators Q#47356, answer score: 10

Revisions (0)

No revisions yet.