| title | sp_dbremove (Transact-SQL) | Microsoft Docs | ||
|---|---|---|---|
| ms.custom | |||
| ms.date | 03/14/2017 | ||
| ms.prod | sql-non-specified | ||
| ms.reviewer | |||
| ms.suite | |||
| ms.technology |
|
||
| ms.tgt_pltfrm | |||
| ms.topic | language-reference | ||
| f1_keywords |
|
||
| dev_langs |
|
||
| helpviewer_keywords |
|
||
| ms.assetid | a8513f4a-c025-49c8-99c3-4c83cb7f51ed | ||
| caps.latest.revision | 32 | ||
| author | BYHAM | ||
| ms.author | rickbyh | ||
| manager | jhubbard |
[!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.
| Applies to: [!INCLUDEssNoVersion] ([!INCLUDEssKatmai] through current version). |
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)