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
>
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