Redigera

Dela via


sp_dbremove (Transact-SQL)

Applies to: SQL Server

Removes a database and all files associated with that database.

Important

This feature will be removed in a future version of SQL Server. Avoid using this feature in new development work, and plan to modify applications that currently use this feature. We recommend that you use DROP DATABASE instead.

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.

EXEC sp_dbremove sales;