Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Can anyone help me on this regarding by providing the exact code?

I need to create two Logins named (Groups) 1. Dev_S 2. Dev_T

Each Group has exactly fifty (50) Users (as Dev_S1, Dev_S2, Dev_S3 so on) in it.

How can I add these 50 users to the Groups.

Out of 50 users in each groups only 5 users needs db_datawriter rights and the rest needs db_datareader rights.

How can I grant access to these users?

Thanks in advance.

Regards,

Krish.

share|improve this question
add comment

1 Answer

If I understand where you are trying to go, have your Active Directory administrator create your groups based upon the access they will be given and have each of the appropriate users added to their respective group.

In SQL Server you then run:

CREATE LOGIN [Domain\LoginName] FROM WINDOWS WITH DEFAULT_DATABASE = [master] GO

Followed by

USE DatabaseName EXEC sp_addrolemember N'db_datareader','[Domain\LoginName]'

All of the users your AD Admin placed into group LoginName now have db_datareader access to database DatabaseName.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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