I cannot add user to database/cannot add new databases through 3rd party app

Mariusz Kuc 21 Reputation points
2023-03-14T19:33:41.01+00:00

Hi!

I cannot add user to database/cannot add new databases through 3rd party app, overall cannot add users and roles because i dont have permissions, and i am the owner of database, because i have setted it up on Azure platform, i've tried with commands in t-sql but it is showing: Do you have any ideas?

User's image

Azure SQL Database
Microsoft Security Microsoft Entra Microsoft Entra ID
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Alberto Morillo 34,671 Reputation points MVP Volunteer Moderator
    2023-03-15T03:43:06.7566667+00:00

    If you are creating users in the traditional SQL Server way, first connect to the master database and create the login there.

    CREATE LOGIN MyServerLogin WITH password='My#Password123'
    

    After that you need to create the user on the user database. Get connected to the user database (the Azure SQL database you created) and then create the user based on the login previously created.

    CREATE USER MyDatabaseUser FROM LOGIN MyServerLogin;
    

    Alternatively, instead of creating a user in the traditional way you can create the new user as a contained user. You just have to connect to the database and use the following syntax:

    CREATE USER [databaseUser] WITH PASSWORD = 'xxxxxxxxxxx';
    ALTER ROLE [db_datareader] ADD MEMBER [databaseUser]
    

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.