Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.



share|improve this question

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:


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

Your Answer


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.