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"

Running  MsDtsServer100     SQL Server Integration Services 10.0Running  MsDtsServer110     SQL Server Integration Services 11.0Running  MsDtsServer130     SQL Server Integration Services 13.0Running  MSSQL$SQL2008R2    SQL Server (SQL2008R2)Running  MSSQL$SQL2012      SQL Server (SQL2012)Running  MSSQL$SQL2016      SQL Server (SQL2016)Running  MSSQLFDLauncher$S. SQL Full-text Filter Daemon Launcher .Running  MSSQLFDLauncher$S. SQL Full-text Filter Daemon Launcher .Running  MSSQLFDLauncher$S. SQL Full-text Filter Daemon Launcher .Stopped  MSSQLServerADHelp. SQL Active Directory Helper ServiceRunning  SQLAgent$SQL2008R2 SQL Server Agent (SQL2008R2)Running  SQLAgent$SQL2012   SQL Server Agent (SQL2012)Running  SQLAgent$SQL2016   SQL Server Agent (SQL2016)Running  SQLBrowser         SQL Server BrowserRunning  SQLTELEMETRY$SQL2. SQL Server CEIP service (SQL2016)Running  SQLWriter          SQL Server VSS WriterRunning  SSISTELEMETRY130   SQL Server Integration Services CEIP .Running  TSM  Client Accep. TSM  Client Acceptor SQLStopped  TSM Remote Client. TSM Remote Client Agent 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

TimeCreated                     Id LevelDisplayName Message-----------                     -- ---------------- -------06/10/2024 11:48:55           1074 Information      The process C:\Program Files\VMware\VMware Tools\vmtoolsd.exe (MYHOST) has initiated the shutdown of                                                     computer MYHOST on behalf of user NT AUTHORITY\SYSTEM for the following reason: Legacy API shutdown.
06/10/2024 09:50:35           1074 Information      The process C:\windows\system32\winlogon.exe (MYHOST) has initiated the restart of computer MYHOST on                                                    behalf of user MYDOMAIN\myuser for the following reason: No title for this reason could be found.
06/10/2024 09:50:27           1074 Information      The process wusa.exe has initiated the restart of computer MYHOST on behalf of user MYDOMAIN\myuser for                                                    the following reason: Operating System: Recovery (Planned).
06/10/2024 07:34:52           1074 Information      The process C:\windows\servicing\TrustedInstaller.exe (MYHOST) has initiated the restart of computer                                                    MYHOST on behalf of user NT AUTHORITY\SYSTEM for the following reason: Operating System: Upgrade                                                    (Planned).
01/09/2024 01:52:21           1074 Information      The process C:\Program Files (x86)\ManageEngine\UEMS_Agent\bin\dcmsghandler.exe (MYHOST) has initiated                                                    the restart of computer MYHOST on behalf of user NT AUTHORITY\SYSTEM for the following reason: Legacy                                                    API shutdown.
01/09/2024 00:42:12           1074 Information      The process C:\windows\servicing\TrustedInstaller.exe (MYHOST) has initiated the restart of computer                                                    MYHOST on behalf of user NT AUTHORITY\SYSTEM for the following reason: Operating System: Upgrade                                                    (Planned).
01/09/2024 00:18:52           1074 Information      The process C:\windows\system32\shutdown.exe (MYHOST) has initiated the restart of computer MYHOST on                                                    behalf of user MYDOMAIN\myuser for the following reason: No title for this reason could be found.
29/08/2024 20:55:28           1074 Information      The process C:\windows\system32\winlogon.exe (MYHOST) has initiated the restart of computer MYHOST on                                                    behalf of user MYDOMAIN\myuser for the following reason: No title for this reason could be found.
29/08/2024 20:55:25           1074 Information      The process wusa.exe has initiated the restart of computer MYHOST on behalf of user MYDOMAIN\myuser for                                                    the following reason: Operating System: Recovery (Planned).

Other useful diagnostics

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

TimeCreated                     Id LevelDisplayName Message-----------                     -- ---------------- -------06/10/2024 10:05:48          17147 Information      SQL Server is terminating because of a system shutdown. This is an informational message only. No user action is required.

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

Get-WinEvent -ComputerName localhost -FilterHashtable @{logname = 'System'; id = 7036} -MaxEvents 2000 | Out-String -Stream | Select-String -pattern "SQL"

06/10/2024 07:50:45         7036 Information      The SQL Full-text Filter Daemon Launcher (SQL2008R2) service entered the running state.06/10/2024 07:50:45         7036 Information      The SQL Full-text Filter Daemon Launcher (SQL2012) service entered the running state.06/10/2024 07:50:43         7036 Information      The SQL Full-text Filter Daemon Launcher (SQL2016) service entered the running state.06/10/2024 07:49:59         7036 Information      The SQL Server Agent (SQL2016) service entered the running state.06/10/2024 07:49:58         7036 Information      The SQL Server (SQL2016) service entered the running state.06/10/2024 07:49:55         7036 Information      The TSM Remote Client Agent SQL service entered the running state.06/10/2024 07:49:54         7036 Information      The TSM  Client Acceptor SQL service entered the running state.06/10/2024 07:49:50         7036 Information      The SQL Server Integration Services CEIP service 13.0 service entered the running state.06/10/2024 07:49:50         7036 Information      The SQL Server VSS Writer service entered the running state.06/10/2024 07:49:49         7036 Information      The SQL Server CEIP service (SQL2016) service entered the running state.06/10/2024 07:49:47         7036 Information      The SQL Server Browser service entered the running state.06/10/2024 07:49:47         7036 Information      The SQL Server Agent (SQL2012) service entered the running state.06/10/2024 07:49:47         7036 Information      The SQL Server Agent (SQL2008R2) service entered the running state.06/10/2024 07:49:44         7036 Information      The SQL Server (SQL2012) service entered the running state.06/10/2024 07:49:43         7036 Information      The SQL Server (SQL2008R2) service entered the running state.06/10/2024 07:49:39         7036 Information      The SQL Server Integration Services 11.0 service entered the running state.06/10/2024 07:49:39         7036 Information      The SQL Server Integration Services 13.0 service entered the running state.06/10/2024 07:49:31         7036 Information      The SQL Server Integration Services 10.0 service entered the running state.06/10/2024 07:35:38         7036 Information      The SQL Server Agent (SQL2016) service entered the running state.06/10/2024 07:35:35         7036 Information      The TSM Remote Client Agent SQL service entered the running state.06/10/2024 07:35:35         7036 Information      The TSM  Client Acceptor SQL service entered the running state.06/10/2024 07:35:34         7036 Information      The SQL Server (SQL2016) service entered the running state.06/10/2024 07:35:31         7036 Information      The SQL Server Integration Services CEIP service 13.0 service entered the running state.06/10/2024 07:35:28         7036 Information      The SQL Server VSS Writer service entered the running state.06/10/2024 07:35:28         7036 Information      The SQL Server CEIP service (SQL2016) service entered the running state.06/10/2024 07:35:23         7036 Information      The SQL Server Agent (SQL2012) service entered the running state.06/10/2024 07:35:23         7036 Information      The SQL Server Browser service entered the running state.06/10/2024 07:35:22         7036 Information      The SQL Server Agent (SQL2008R2) service entered the running state.06/10/2024 07:35:18         7036 Information      The SQL Server (SQL2012) service entered the running state.06/10/2024 07:35:15         7036 Information      The SQL Server (SQL2008R2) service entered the running state.06/10/2024 07:35:09         7036 Information      The SQL Server Integration Services 13.0 service entered the running state.06/10/2024 07:35:09         7036 Information      The SQL Server Integration Services 11.0 service entered the running state.06/10/2024 07:35:01         7036 Information      The SQL Server Integration Services 10.0 service entered the running state.

Bibliography