| 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 |
|
||
| helpviewer_keywords |
|
||
| dev_langs |
|
[!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
sp_dbremove
[ [ @dbname = ] N'dbname' ]
[ , [ @dropdev = ] 'dropdev' ]
[ ; ]
The name of the database to be removed. @dbname is sysname, with a default of NULL.
A flag provided for backward compatibility only and is currently ignored. @dropdev is varchar(10), with a default of dropdev.
0 (success) or 1 (failure).
None.
Requires membership in the sysadmin fixed server role, or execute permission directly on this stored procedure.
The following example removes a database named sales and all files associated with it.
EXECUTE sp_dbremove sales;