Updated on 2023-08-09 GMT+08:00

Deleting Custom Databases

Scenarios

You can use a stored procedure to delete a custom database.

Prerequisites

An RDS for SQL Server DB instance has been connected. For details about how to connect to a DB instance, see Connecting to a DB Instance.

Constraints

  • This stored procedure cannot be used to delete system databases. If you attempt to delete a system database, the system displays the following information:
    Error DBName can not  in ('msdb','master','model','tempdb','rdsadmin','resource') .
  • The stored procedure cannot be used to delete a database that does not exist. If you attempt to delete a database that does not exist, the system displays the following information:
    Cannot find database XXX.

Procedure

Run the following command to delete a custom database:

EXEC rdsadmin.dbo.rds_drop_database '@DBName';

In the preceding command, @DBName indicates the name of the database to be deleted.

For example, to delete custom database testDB_1, run the following command:

EXEC rdsadmin.dbo.rds_drop_database 'testDB_1';