EXECUTE AS USER failed for the requested user dbo in the database

自闭症网瘾萝莉.ら 提交于 2021-01-27 07:31:25

问题


Using sql server 2008.

First, I am not a DBA. But I can get around a db when it comes to sp's, triggers, tables, creating and normalizing. I'm a developer.

But with this new job, I inherited a large database that has many jobs that run.

My predecessor's account was disabled and of course a few jobs started to fail.

After searching around and testing and failing, I now need to post for some input on this problem.

The job fails when executing a stored procedure and I have checked it. It is updating the database in question.

First, I have changed the owner of the job:

 EXEC MSDB.dbo.sp_update_job 
 @job_name = 'MyJob', 
 @owner_login_name = 'NT AUTHORITY\SYSTEM' 
 GO 

I have tried the sa account, sqlserveragent, and others but the same error occurs. And I made sure these new owners had the correct permissions for that database.

EXECUTE AS USER failed for the requested user dbo in the database MyDB.

The user never changes in the error message from the dbo user, even after I change the job owner.

Does anyone have any other suggestions that I may have overlooked?

Thanks,

UPDATE:

The problem has been solved. Learned something new today!

Take a look at this post: http://blog.strictly-software.com/2009/09/database-owner-sid-recorded-in-master.html

I hope this helps someone else in the future as I wasted some time on this problem and it took one small line of sql to fix it. Always seems to be that way, doesn't it?


回答1:


The problem has been solved. Learned something new today!

Take a look at this post: http://blog.strictly-software.com/2009/09/database-owner-sid-recorded-in-master.html

I hope this helps someone else in the future as I wasted some time on this problem and it took one small line of sql to fix it. Always seems to be that way, doesn't it?




回答2:


Make the Database Trustworthy on your server:

ALTER DATABASE AdventureWorks2012 SET TRUSTWORTHY ON

Make the Job's owner be the same login that owns the Database:

USE AdventureWorks2012
GO
EXEC sp_changedbowner 'Nathan'
GO


来源:https://stackoverflow.com/questions/20051234/execute-as-user-failed-for-the-requested-user-dbo-in-the-database

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!