Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Azure by (45.3k points)

I would like to create an SQL Azure user and grant it read-only access on a handful of Databases, what script can I use to achieve this?

1 Answer

0 votes
by (16.8k points)

Give a try to this, in your Master DB:

CREATE LOGIN reader WITH password='YourPWD';

-- grant public master access

CREATE USER readerUser FROM LOGIN reader;

For Each targeted Database, which requires seperate connection:

CREATE USER readerUser FROM LOGIN reader;

EXEC sp_addrolemember 'db_datareader', 'readerUser';

Hope it helps!

Browse Categories

...