SQL Server job error

SQL Server 2008 R2

I've created a SQL Server job which will run several consecutive stored procedures.  These procedures pull data from a linked server "XXX-P2DB" and dump it into several tables in a database on my primary server.  When I run these procedures separately, they each succeed, but when I run these procedures in the job, I'm getting the following error message:

Executed as user: XXX\administrator.
The OLE DB provider "SQLNCLI10" for linked server "XXX-P2DB" reported an error. Authentication failed. [SQLSTATE 42000] (Error 7399)  
Cannot initialize the data source object of OLE DB provider "SQLNCLI10" for linked server "XXX-P2DB". [SQLSTATE 42000] (Error 7303)  
OLE DB provider "SQLNCLI10" for linked server "XXX-P2DB" returned message "Invalid authorization specification". [SQLSTATE 01000] (Error 7412).  The step failed.

The job steps look like:job stepsand the job step properties look like:job step properties
LVL 52
Dale FyeOwner, Developing Solutions LLCAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

the last time I ran into the exact same error it was because the windows firewall was enabled. disabling it fixed the issue.
Dale FyeOwner, Developing Solutions LLCAuthor Commented:
I don't understand how the SPs would work when run individually, but not as part of a Job if it was a windows firewall issue.
Deepak ChauhanSQL Server DBACommented:
Go to the advance option in JOB step and set the RUN as user which you are using in linked server.
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

Dale FyeOwner, Developing Solutions LLCAuthor Commented:

OK, I changed the Run As for each of the steps in the job to my domain userid:  DomainName\myName

which is one of the names in the Security \ Logins section of the other server.  Now I'm getting the error:

Executed as user: DomainName\myName.
Access to the remote server is denied because the current security context is not trusted. [SQLSTATE 42000] (Error 15274).  The step failed.
Dale FyeOwner, Developing Solutions LLCAuthor Commented:
I may have worded my initial question wrong.  The data is being pulled from another server on our network, not a "linked server".

In my stored procedure, I have to refer to the tables in this other server with a 4 part identifier:

Deepak ChauhanSQL Server DBACommented:
The account you are using to access to remote server (network server) must have reuired permissions there like connect permission at server level and at least select permission at database level.
Dale FyeOwner, Developing Solutions LLCAuthor Commented:

my userid has:
public permissions under Server Roles and
db_datareader permissions on the database I'm trying to pull data from.

Is that sufficient?

I don't understand why these SPs work when I run them manually, but not in the Job?
Deepak ChauhanSQL Server DBACommented:
Yes this is fine only for select data.
And you are using linked server, check teh linked server folder and go to linked server name property , check the login you have mapped with remote server.

here is the link for steps to resolve this problem.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Dale FyeOwner, Developing Solutions LLCAuthor Commented:
Thanks, between removing the Run as User values, and then setting the security setting of the linked server to: Be made using the lgin's current security context

it is now working.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2008

From novice to tech pro — start learning today.