| title | sp_dbremove (Transact-SQL) | Microsoft Docs | ||
|---|---|---|---|
| ms.custom | |||
| ms.date | 03/14/2017 | ||
| ms.prod | sql | ||
| ms.prod_service | database-engine | ||
| ms.reviewer | |||
| ms.technology | system-objects | ||
| ms.topic | language-reference | ||
| f1_keywords |
|
||
| dev_langs |
|
||
| helpviewer_keywords |
|
||
| ms.assetid | a8513f4a-c025-49c8-99c3-4c83cb7f51ed | ||
| author | stevestein | ||
| ms.author | sstein |
[!INCLUDEtsql-appliesto-ss2008-xxxx-xxxx-xxx-md]
Removes a database and all files associated with that database.
Important
[!INCLUDEssNoteDepFutureAvoid] We recommend that you use DROP DATABASE instead.
Transact-SQL Syntax Conventions
sp_dbremove [ @dbname = ] 'database' [ , [ @dropdev = ] 'dropdev' ]
[ @dbname = ] 'database'
Is the name of the database to be removed. database is sysname, with a default value of NULL.
[ @dropdev = ] 'dropdev'
Is a flag provided for backward compatibility only and is currently ignored. dropdev has the value dropdev.
0 (success) or 1 (failure)
None
Requires membership in the sysadmin fixed server role.
The following example removes a database named sales and all files associated with it.
EXEC sp_dbremove sales;
ALTER DATABASE (Transact-SQL)
CREATE DATABASE (SQL Server Transact-SQL)
DBCC (Transact-SQL)
sp_detach_db (Transact-SQL)