Updated on 2024-10-14 GMT+08:00

Granting Permissions of Database-Level db_owner Role

Scenarios

You can use a stored procedure to grant the db_owner role permissions of a database to a specified user.

Precautions

  • The stored procedure can be executed only by the rdsuser user or the database login account. The login account has all the permissions of the rdsuser user on RDS for SQL Server instances. For details about the stored procedure for creating a database login account, see Creating a Database Account.
  • The database you will grant the permissions for cannot be any of the following system databases: msdb, master, model, tempdb, rdsadmin, and resource.
  • Permissions of the db_owner role can be granted to rdsuser.

Prerequisites

An RDS for SQL Server DB instance has been connected. For details, see Connecting to a DB Instance Through a Public Network.

Procedure

Run the following command to grant permissions of the db_owner role to a specified user:

EXEC master.dbo.rds_add_db_owner @dbname, @user;

  • @dbname: name of the database
  • @user: name of the user

Example

Grant the db_owner role permissions of the database testdb to testuser:

EXEC master.dbo.rds_add_db_owner @dbname='testdb',@user='testuser';