当前位置:Gxlcms > 数据库问题 > The server principal "sa" is not able to access the database "xxxx" under the current security context

The server principal "sa" is not able to access the database "xxxx" under the current security context

时间:2021-07-01 10:21:17 帮助过:17人阅读

在SQL Server服务器上一个作业执行时,遇到下面错误信息:

Message:

Executed as user: dbo. The server principal "sa" is not able to access the database "xxxx" under the current security context. [SQLSTATE 08004] (Error 916). The step failed.

技术分享

 

作业本身执行的存储过程非常简单,就是将数据库A中的历史数据处理过后,归档到A_History库中,结果就遇到这么一个问题。将作业的存储过程取出在SSMS客户端执行成功,没有问题,但是作业执行就遇到这个从我。后面折腾了一下,终于弄清楚了原委。 原来这个作业步骤的“Advanced”选项里面,设置成了Run as user 为dbo。

技术分享

 

取消这个选项,问题即可解决。个人设置作业时从不设置此选项,但是有一些开发人员创建的作业就设置了此处选项,结果遇到了这个问题。

 

另外。我这篇博客SQL Agent Job 报“Access to the remote server is denied because the current security context is not trusted”里面遇到的其实也是这个问题。可笑当时虽然解决了,阴错阳差的解决了问题,但是还是没有找到Root Cause。 依此为戒!

The server principal "sa" is not able to access the database "xxxx" under the current security context

标签:inline   执行   security   数据处理   存储过程   style   server   images   under   

人气教程排行