In some scenario we need to create the db user and assign the some db role to that user. here is the script which will create the user and role.
- USE Portal_PS;
- GO
- GRANT EXECUTE TO db_executor;
- GO
-
- CREATE USER DBUser for LOGIN DBUser;
- GO
- EXEC sys.sp_addrolemember 'db_datareader','DBUser';
- GO
- EXEC sys.sp_addrolemember 'db_datawriter','DBUser';
- GO
- EXEC sys.sp_addrolemember 'db_executor','DBUser';
- GO
In this scripts we are giving the DBuser to three roles.