Solved

Error message when scheduling a job using a linked Server

Posted on 2016-09-07
12
49 Views
Last Modified: 2016-09-15
Getting error message when running a job when scheduling a job using a linked Server.  It fails when it runs the following statements below. Screenshots are attached. Both scripts run fine in a query window. Any insight will be appreciated.

SELECT * into WOMAST01B FROM OPENQUERY(ATQAV, 'SELECT * FROM WOMAST01 where 1=0')
SELECT * into WOLABO01B FROM OPENQUERY(ATQAV, 'SELECT * FROM wolabo01 where 1=0')

Open in new window

Capture.PNG
Capture2.PNG
0
Comment
Question by:maximus1974
  • 5
  • 5
12 Comments
 
LVL 7

Expert Comment

by:Dung Dinh
ID: 41788993
It looks like SQL Agent Job account has not been granted permissions on the LINKED SERVER. Be aware of this,  whenever you run any statement via SQL Agent Job, it uses SQLAGENTSERVICE account to execute your statements by default. In case, the account has not permission on the linked server, it will be failed.

From your attached files, you run the statements under System Administration account so they were run successfully. Please check your SQL Agent Service account and be sure that you must grant permissions appropriately to the account.

Another way, you can create Proxy Account in SQL Server  to run SQL Agent Job instead of using SQL Agent Account by default.
0
 
LVL 45

Expert Comment

by:Vitor Montalvão
ID: 41789255
Is the Linked Server using the current user credentials or it has his own security credentials?
0
 

Author Comment

by:maximus1974
ID: 41790213
The linked Server has it's own credentials used ot authenticate against another network. I am linking an old Foxpro DBF database to SQL Server then importing the DBF into SQL. Currently, the SQL Server agent can authenticate on network it is on.

Does this mean the SQL agent will need access to authenticate against the linked Server on the other network? what happens to the jobs that run on it now which authenticate against a different network than the linked Server?
0
 
LVL 45

Expert Comment

by:Vitor Montalvão
ID: 41795503
Apologizes for not returning to this question. I just missed the mail informing that you posted here.
So, if you have the credentials stored with the Linked Server then it should work. Did you try to open the Linked Server to perform a connection test?
0
 

Author Comment

by:maximus1974
ID: 41797225
Vitor responded.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:maximus1974
ID: 41797236
When I run a query or insert statement from the query Window against the linked Server, it works fine so this proves I am able ot authenticate against the linked Server. However, when i attempt to schedule an import, I am getting invalid path or file name as illustrated in the attached screenshots above.

When you say to use the correct credentials in the SQL agent service, do you mean here?
screenshot
0
 
LVL 45

Expert Comment

by:Vitor Montalvão
ID: 41797384
It shouldn't have nothing with the SQL Server Agent as you said the Linked Server has an user and password configured.
But just for sanity check and if you can change the SQL Server Agent to a non Local System account it will be a good test because Local System account doesn't have access on the network.
0
 

Author Comment

by:maximus1974
ID: 41798699
screenshots and errors attached. Queries against the linked Server works via the query window, when manually importing via SISS,  executing the package via integrated services. however, when scheduled via a SQL agent job is fails stating : invalid file name or path".
Capture.PNG
Capture2.PNG
Capture3.PNG
Capture4.PNG
0
 
LVL 45

Expert Comment

by:Vitor Montalvão
ID: 41799261
when scheduled via a SQL agent job is fails stating : invalid file name or path".
That's a new information and very important one. This means it has nothing to do with the Linked Server but the permissions to access a file in the network.
A Local System account has no privileges in the network and that's why is returning that error. You need to provide an AD account that has access to the file through the network.
0
 

Author Comment

by:maximus1974
ID: 41799863
I have since changed it to an AD accoutn with permission to the directory and i am receiving the same error. If it's permissions, how come it works using all other means except vai the SQL agent job?

new screenshot attached.
Capture.PNG
0
 
LVL 45

Accepted Solution

by:
Vitor Montalvão earned 500 total points
ID: 41800034
If it's permissions, how come it works using all other means except vai the SQL agent job?
Because you're not using the same user for the other process, right?
Btw, do you also have an AD account for the SQL Server service?
And for the user that is running the job also? A SQL Login doesn't have access to network.
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now