db_datareader permission for a login

  • we have 15 Database in our server how can i give at a time db_datareader permission for all DB 's for One login

  • Something like this:

    SELECT 'USE ' + name + ' EXEC sp_addrolemember ''db_datareader'', ''myusername'''

    FROM master..sysdatabases

    That will generate the SQL to add the user to the role in each database. This assumes that the login is mapped to the same user name in each database.

    John

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

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