the database principal owns a service in the database -- can't drop a user

来源:互联网 发布:对项羽的评价 知乎 编辑:程序博客网 时间:2024/05/16 13:41

There are two options here.
 
 
1. You map orphan user to login if user is required. sp_change_users_login


 
2. Run below code and check which service user owns.
 
select s.name as ServiceName
from    sys.database_principals p
        inner join sys.services s on p.principal_id = s.principal_id
where p.name = 'nimit' --User Name (which you trying to delete)
 

It will give you list of Services Owned by that User. Now to remove this dependancy you have to ALTER SERVICE AUTHORIZATION by running below query. If there are multiple services than run below code for all services.
 
--Here nimit is the ServiceName I got from above query
ALTER AUTHORIZATION ON Service::nimit TO [dbo] --Transfer Service Authorization to dbo

0 0
原创粉丝点击