Transact-SQL Reference

SHUTDOWN

Immediately stops Microsoft® SQL Server™.

Syntax

SHUTDOWN [ WITH NOWAIT ]

Arguments

WITH NOWAIT

Shuts down SQL Server immediately, without performing checkpoints in every database. SQL Server exits after attempting to terminate all user processes, and a rollback operation occurs for each active transaction.

Remarks

Unless members of the sysadmin fixed server role specify the WITH NOWAIT option, SHUTDOWN tries to shut down SQL Server in an orderly fashion by:

  1. Disabling logins (except for members of the sysadmin fixed server role). To see a listing of all current users, execute sp_who.

  2. Waiting for currently executing Transact-SQL statements or stored procedures to finish. To see a listing of all active processes and locks, execute sp_lock and sp_who.

  3. Performing 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 SQL Server.

These tools and methods can also be used to stop SQL Server. Each of these performs a checkpoint in all databases. All committed data from data cache is flushed, and then the server is stopped:

If sqlservr.exe was started from the command-prompt, pressing CTRL+C shuts down SQL Server. However, pressing CTRL+C does not perform a checkpoint.

Note  The SQL Server Enterprise Manager, net stop, Control Panel, and SQL Server Service Manager methods of stopping SQL Server produce the identical service control message of SERVICE_CONTROL_STOP to SQL Server.

Permissions

SHUTDOWN permissions default to members of the sysadmin and serveradmin fixed server roles, and are not transferable.

See Also

CHECKPOINT

sp_lock

sp_who

sqlservr Application

Stopping SQL Server