Read Only access to all databases to a user in a SQL Server Instance

  • juneja.gauravdeep

    SSC Journeyman

    Points: 88

    Comments posted to this topic are about the item Read Only access to all databases to a user in a SQL Server Instance

  • tskelley

    SSCommitted

    Points: 1869

    Hi and thanks for taking the time to post your script.  It appears a space is missing before the 'FOR LOGIN' in the dynamic sql below:


    SELECT @SQL = 'USE '+ '[' + @DatabaseName + ']' +'; '+ 'CREATE USER ' + @User +     'FOR LOGIN ' + @User + '; EXEC sp_addrolemember N''db_datareader'',     ' + @User + '';


    Again, many thanks, and like that you factored in system and logshipped db's.

    Take care,
    Tom

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

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