MSSQL Downtime
Uptime/Downtime
Uptime/Downtime
To find out if SQL Server is down...
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...
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...
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
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.
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.
Bibliography
Bibliography
https://www.prajwaldesai.com/restarted-windows-server/https://www.lifewire.com/net-command-2618094https://www.digitalcitizen.life/ways-access-services-windows/https://www.prajwaldesai.com/restarted-windows-server/https://www.coretechnologies.com/blog/windows-services/event-viewer-troubleshoot-windows-services/
Powershellhttps://stackoverflow.com/questions/64183006/how-to-use-select-string-to-filter-lines-from-an-outputhttps://stackoverflow.com/questions/56083896/powershell-script-to-filter-windows-event-logshttps://adamtheautomator.com/powershell-grep/https://gallery.technet.microsoft.com/scriptcenter/Get-Windows-Servers-last-a6edfe89