0 votes
1 view
in Azure by (33.1k 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 !


Categories

...