Linked Server failing on SQL Server job

北城余情 提交于 2019-12-19 22:12:12

问题


I have a linked server that perfectly works when executing a query. But when I place the query in a job, it fails.

Here is the setting of my linked server

Error


回答1:


Read SQL Server Agent job fails when the job uses a linked server.

WORKAROUND To work around this problem, use one of the following methods:

Method 1

Make the system administrator the owner of the job.

Method2:

Use mapped security context for the linked server and modify the job to run as OSQL.

To set the mapped security context for the linked server: Right-click the linked server, and then click Properties. Click the Security tab. Select either of the following options. Be made using the login's current security context Be made using this security context To modify the job to run as OSQL: Right-click the job, and then click Properties. In the Steps tab, click the Step Name that you want to edit, and then click Edit. On the General tab of the Edit Job Step dialog box, click Operating System Command (CmdExec) in the Type list. In the Command text box, type osql –E –Q “Exec storedProcedure”. In the Edit Job Step dialog box, click OK. In the Properties dialog box, click OK.

In linked server definition tick: Be made using the login's current security context




回答2:


I had this same issue, And after changing user permissions etc etc etc, I found this article and instead of using "Be made using the login's current security context" i used "Be made using this security context" and i specified the account and password which solved the issue. So the issue isnt with SQL jobs or my procedure it was in actual fact my linked server. Even though the link server did work... When calling a linked server within a SQL job the linked server had to have the account details specifically specified.



来源:https://stackoverflow.com/questions/32477446/linked-server-failing-on-sql-server-job

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