I need to give a new login read access to all 300 databases on a server. How can I accomplish this without checking 300 checkboxes in the user mapping area?
EXEC sp_MSForEachDB 'Declare @name varchar(100) select @name = ''?'' PRINT @name IF db_id(@name) > 4 BEGIN USE ? CREATE USER [user] FOR LOGIN [user]; EXEC sp_addrolemember ''db_datareader'', ''user'' END'