Explore Courses Blog Tutorials Interview Questions
0 votes
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!
Welcome to Intellipaat Community. Get your technical queries answered by top developers!

29.3k questions

30.6k answers


104k users

Browse Categories