Share via

why can I not query a SQL database in Azure

Jenn Rolfes 0 Reputation points
2025-03-01T21:06:47.7833333+00:00

I am a user access administrator for a SQL Server and SQL Database in Azure and have been unable to give access to my colleague to query the SQL database. Please let me know how I can configure it appropriately.

Azure SQL Database
0 comments No comments

3 answers

Sort by: Most helpful
  1. Anonymous
    2025-03-03T03:57:52.7666667+00:00

    Just checking in to see if the above answer provided by @Amira Bedhiafi helped.

    If this answers your query, do click Accept Answer and Yes for was this answer helpful. And, if you have any further query do let us know.

    Was this answer helpful?

    0 comments No comments

  2. Amira Bedhiafi 42,941 Reputation points MVP Volunteer Moderator
    2025-03-02T12:48:30.3333333+00:00

    If your SQL Database uses SQL Authentication, you need to create a login for your colleague.

    
       CREATE LOGIN [username] WITH PASSWORD = 'strong_password';
    
    

    After creating the login, you need to create a user in the specific database and map it to the login.

    
       CREATE USER [username] FOR LOGIN [username];
    

    Grant the necessary permissions to the user. For querying, you typically need to grant the SELECT permission.

    
       GRANT SELECT ON SCHEMA::[schema_name] TO [username];
    
    

    If you want to grant more permissions, you can use roles like db_datareader:

    
       ALTER ROLE db_datareader ADD MEMBER [username];
    
    

    If your SQL Database uses Azure Active Directory (AAD) authentication, you need to add your colleague as a user in the database.

    
       CREATE USER [******@domain.com] FROM EXTERNAL PROVIDER;
    
    

    Then, grant the necessary permissions:

    
       GRANT SELECT ON SCHEMA::[schema_name] TO [******@domain.com];
    
    

    Was this answer helpful?


  3. Marcin Policht 92,635 Reputation points MVP Volunteer Moderator
    2025-03-01T21:16:12.5066667+00:00

    Follow https://learn.microsoft.com/en-us/answers/questions/1512228/cannot-add-user-to-db-datareader-role-in-database


    If the above response helps answer your question, remember to "Accept Answer" so that others in the community facing similar issues can easily find the solution. Your contribution is highly appreciated.

    hth

    Marcin

    Was this answer helpful?


Your answer

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