Skip to content

Latest commit

 

History

History
74 lines (52 loc) · 2.03 KB

File metadata and controls

74 lines (52 loc) · 2.03 KB
title sp_dbremove (Transact-SQL)
description sp_dbremove removes a database and all files associated with that database.
author markingmyname
ms.author maghan
ms.reviewer randolphwest
ms.date 06/23/2025
ms.service sql
ms.subservice system-objects
ms.topic reference
f1_keywords
sp_dbremove
sp_dbremove_TSQL
helpviewer_keywords
sp_dbremove
dev_langs
TSQL

sp_dbremove (Transact-SQL)

[!INCLUDE SQL Server]

Removes a database and all files associated with that database.

Important

[!INCLUDE ssNoteDepFutureAvoid] We recommend that you use DROP DATABASE instead.

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

Syntax

sp_dbremove
    [ [ @dbname = ] N'dbname' ]
    [ , [ @dropdev = ] 'dropdev' ]
[ ; ]

Arguments

[ @dbname = ] N'dbname'

The name of the database to be removed. @dbname is sysname, with a default of NULL.

[ @dropdev = ] 'dropdev'

A flag provided for backward compatibility only and is currently ignored. @dropdev is varchar(10), with a default of dropdev.

Return code values

0 (success) or 1 (failure).

Result set

None.

Permissions

Requires membership in the sysadmin fixed server role, or execute permission directly on this stored procedure.

Examples

The following example removes a database named sales and all files associated with it.

EXECUTE sp_dbremove sales;

Related content