MSSQL Downtime

Uptime/Downtime

To find out if SQL Server is down...

services.msc

or (via Powershell)...

Get-Service | Out-String -Stream | Select-String -pattern "SQL"

To find out how long SQL Server has been up...

SELECT sqlserver_start_time

FROM sys.dm_os_sys_info;

or

SELECT create_date AS SQLServerStartTime

FROM sys.databases

WHERE name = 'tempdb';

To find out who restarted Windows...

eventvwr

Windows Logs - System - Filter Current Log and type 1074 as the event ID.

If you double click the restart event you are interested in you should see the userid of the person who initiated the restart in the event properties window.

or (via Powershell)...

Get-WinEvent -ComputerName localhost -FilterHashTable @{logname="System";id="1074"} -MaxEvents 10

Other useful diagnostics

Get-WinEvent -ComputerName localhost -FilterHashtable @{logname = 'Application'; id = 17147} -MaxEvents 1

ProviderName: MSSQLSERVER
TimeCreated Id LevelDisplayName Message----------- -- ---------------- -------22/11/2022 22:53:10 17147 Information SQL Server is terminating because of a system shutdown. This is an informational message only. No user action is required.