November 16, 2017 at 3:57 pm
Comments posted to this topic are about the item Read Only access to all databases to a user in a SQL Server Instance
November 22, 2017 at 6:19 am
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
January 26, 2023 at 3:19 pm
Thanks, it is very useful!
--------------------------------------
;-)“Everything has beauty, but not everyone sees it.” ― Confucius
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy