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 50
Dale FyeAsked:
Who is Participating?
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.

plusone3055Commented:
the last time I ran into the exact same error it was because the windows firewall was enabled. disabling it fixed the issue.
0
Dale FyeAuthor 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.
0
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.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Dale FyeAuthor Commented:
@deepak,

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.
0
Dale FyeAuthor 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:

 [XXX-P2DB].databaseName.dbo.MeterDailyTb
0
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.
0
Dale FyeAuthor Commented:
@deepak,

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?
0
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.

http://blogs.msdn.com/b/deepakbi/archive/2010/03/03/access-to-the-remote-server-is-denied-because-the-current-security-context-is-not-trusted-sqlstate-42000-error-15274.aspx
0

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 FyeAuthor 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.
0
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.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.