Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

db_datareader permission for a login Expand / Collapse
Author
Message
Posted Monday, November 26, 2012 4:25 AM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Yesterday @ 3:09 AM
Points: 82, Visits: 1,034
we have 15 Database in our server how can i give at a time db_datareader permission for all DB 's for One login

Post #1388519
Posted Monday, November 26, 2012 4:48 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 4:23 AM
Points: 5,317, Visits: 9,743
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
Post #1388530
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse