Tuesday, August 20, 2013

Providing User permissions on DB

IF  EXISTS (SELECT * FROM sys.database_principals WHERE name = alias'')
                                DROP USER [alias]
                                GO
                                CREATE USER [DEV] FOR LOGIN [alias]
                                GO
                                EXEC sp_addrolemember ''db_datareader'', alias''
                                Go