Link to home
Start Free TrialLog in
Avatar of Dale Fye
Dale FyeFlag for United States of America

asked on

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:User generated imageand the job step properties look like:User generated image
Avatar of plusone3055
plusone3055
Flag of United States of America image

the last time I ran into the exact same error it was because the windows firewall was enabled. disabling it fixed the issue.
Avatar of Dale Fye

ASKER

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.
Go to the advance option in JOB step and set the RUN as user which you are using in linked server.
@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.
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
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.
@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?
ASKER CERTIFIED SOLUTION
Avatar of Deepak Chauhan
Deepak Chauhan
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.