This code:
- Create new login.
- Add new user for this login to DB.
- Set full admin rights for this user.
/* -- new admin user login - creation */
if not exists
( select 'x'
from master.sys.server_principals
where
lower( name ) = 'framework_admin'
)
begin
create login framework_admin with password = 's5gh7f5s3', default_database = [master];
end;
/* -- add user for created login to DB */
if not exists
( select 'x'
from sys.database_principals
where
lower( name ) = 'framework_admin'
)
begin
use framework;
create user framework_admin for login framework_admin;
end;
/* -- add all rights */
use framework;
exec sp_addrolemember N'db_owner', N'framework_admin';
No comments:
Post a Comment