Used to remove a database, and optionally, any devices to which it has exclusive use. This system stored procedure is useful primarily with databases created on removable media; however, it can be used on all databases including damaged databases.
sp_dbremove database[, dropdev]
where
This stored procedure removes the entries in sysdatabases and sysusages for the specified database. If the dropdev keyword is included, it also removes from sysdevices all devices of which that database has exclusive use. It does not delete the .DAT files.
If no value is provided, the usage syntax is displayed.
Execute permission defaults to the system administrator and database owner of the database for which the drop will be performed.
This example removes the sales database and removes from sysdevices all devices used exclusively by sales.
sp_dbremove sales, dropdev
master.dbo.sysalternates, master.dbo.spt_values, master.dbo.sysdatabases, master.dbo.sysprocesses
ALTER DATABASE | DBCC |
CREATE DATABASE |