Search code examples
sql-serverazureazure-sql-database

Is there a way to make a user dbo for all AZURES SQL DBs?


I have a user who I have added to the following Azure SQL Server Roles-

##MS_DatabaseConnector##
##MS_DatabaseManager##
##MS_LoginManager##

I thought ##MS_DatabaseManager## would give them dbo access to all the databases. It turns out it will only give them dbo access to databases they create. Is there a way to have them be dbo on each database whether the create it or not? Thanks


Solution

  • As per this MS_DatabaseManager role in Azure SQL Database does not provide the user with dbo access to all databases If you want to access all database with one user you need to create login in master database using below code:

    Create Login <loginName> with password ='<Password>'
    

    enter image description here

    connect database with admins login

    enter image description here

    Create user in all databases with created login using below code:

    CREATE USER <userName> FOR LOGIN <loginName>
    

    And add the DB_owner role to the user using below code:

    ALTER  ROLE  DB_OWNER ADD MEMBER <userName>
    

    enter image description here

    In this way you can access all the databases in the server. Otherwise as @Thom A said create a LOGIN in the Azure Portal with System Administrator privileges.