Created
January 27, 2014 16:35
-
-
Save derekmurawsky/8651988 to your computer and use it in GitHub Desktop.
MSSQL statement to add a user to all databases on a server as a datareader.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sp_msforeachdb 'use [?]; CREATE USER [MyDBUser] FOR LOGIN [MyDBLogin];EXEC sp_addrolemember ''db_datareader'', ''[MyDBUser]''' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment