Skip to content

Latest commit

 

History

History
80 lines (55 loc) · 3.49 KB

File metadata and controls

80 lines (55 loc) · 3.49 KB
title SHUTDOWN (Transact-SQL)
description SHUTDOWN immediately stops SQL Server.
author rwestMSFT
ms.author randolphwest
ms.date 01/16/2025
ms.service sql
ms.subservice t-sql
ms.topic reference
f1_keywords
SHUTDOWN_TSQL
SHUTDOWN
helpviewer_keywords
SQL Server, stopping
shutting down SQL Server
SHUTDOWN statement
stopping SQL Server
immediately stopping SQL Server
dev_langs
TSQL

SHUTDOWN (Transact-SQL)

[!INCLUDE SQL Server]

Immediately stops SQL Server.

:::image type="icon" source="../../includes/media/topic-link-icon.svg" border="false"::: Transact-SQL syntax conventions

Syntax

SHUTDOWN [ WITH NOWAIT ]

Arguments

WITH NOWAIT

Optional. Shuts down [!INCLUDE ssNoVersion] without performing checkpoints in every database. [!INCLUDE ssNoVersion] exits after attempting to terminate all user processes. When the server restarts, a rollback operation occurs for incomplete transactions.

Remarks

Unless the WITH NOWAIT option is used, SHUTDOWN shuts down [!INCLUDE ssNoVersion] by:

  1. Disabling logins (except for members of the sysadmin and serveradmin fixed server roles).

    [!NOTE]
    To display a list of all current users, run sp_who.

  2. Waiting for currently running Transact-SQL statements or stored procedures to finish. To display a list of all active processes and locks, run sp_who and sp_lock, respectively.

  3. Inserting a checkpoint in every database.

Using the SHUTDOWN statement minimizes the amount of automatic recovery work needed when members of the sysadmin fixed server role restart [!INCLUDE ssNoVersion].

Other tools and methods can also be used to stop [!INCLUDE ssNoVersion]. Each of these issues a checkpoint in all databases. You can flush committed data from the data cache and stop the server:

  • By using [!INCLUDE ssNoVersion] Configuration Manager.

  • By running net stop mssqlserver from a command prompt for a default instance, or by running net stop mssql$<instancename> from a command prompt for a named instance.

  • By using Services in Control Panel.

If sqlservr.exe was started from the command prompt, pressing Ctrl+C shuts down [!INCLUDE ssNoVersion]. However, pressing Ctrl+C doesn't insert a checkpoint.

Note

Using any of these methods to stop [!INCLUDE ssNoVersion] sends the SERVICE_CONTROL_STOP message to [!INCLUDE ssNoVersion].

Permissions

SHUTDOWN permissions are assigned to members of the sysadmin and serveradmin fixed server roles, and they aren't transferable.

Related content