Add users with read permissions

  • Hi All,

          We have over 70 databases and over 100 developers. Each developer is a dbo on certain databases. Can anyone tell me how to add users to all database and grant them read only permissions. This can be done manually but I would like to know of a better way. Thanks.

  • try to write a script using  sp_adduser sps

  • exec sp_msforeachdb "use ?;exec sp_adduser 'username', 'username';"

    exec sp_msforeachdb "use ?;exec sp_addrolemember 'db_datareader', 'username';"

     

    You could use a cursor to loop through the list of users that you want to add.



    Shamless self promotion - read my blog http://sirsql.net

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply