0

I have 2 azure databases created in one SQL Server. I.e.

  1. Database 1 = db1 in xsqldb01.database.windows.net
  2. Database 2 = db2 in xsqldb01.database.windows.net

I would like to create a username or user login where I can read only data (Select grant only) of both databases. How can I achieve this? Do I need to create a user login with same name in both database?

1

You can create Login in master database using syntax ..

CREATE LOGIN <SQL_login_name, sysname, login_name> 
    WITH PASSWORD = '<password, sysname, Change_Password>' 
GO

and then create user in individual databases using syntax

CREATE USER <user_name, sysname, user_name>
    FOR LOGIN <login_name, sysname, login_name>
    WITH DEFAULT_SCHEMA = <default_schema, sysname, dbo>
GO

GRANT SELECT  TO <user_name>

This can be done via SSMS from local machine or VM. I believe you can achieve this using Query Editor in Azure as it does not allow switching context to master database .

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.