March 16, 2018 at 11:53 am
Hi,
I've been pulling my hair out for 2 days on this... I hope someone can help as I have a hard deadline and cannot get past this maddening linked server problem.
The goal is to run an Agent job that will call a stored procedure. The stored proc uses a Linked server in order to load data from Excel documents stored on the local (to SQL server) file system. It works when I run it manually myself but fails from the SQL Agent job...
Version: SQL Server 2012, SP 3, x64
Linked Server definition: EXEC master.dbo.sp_addlinkedserver @server = N'UPLOAD_G', @srvproduct=N'Excel', @provider=N'Microsoft.ACE.OLEDB.12.0', @datasrc=N'D:\dataUpload\upload_G.xlsx', @provstr=N'Excel 12.0'
EXEC master.dbo.sp_addlinkedsrvlogin @rmtsrvname=N'UPLOAD_G',@useself=N'True',@locallogin=NULL,@rmtuser=NULL,@rmtpassword=NULL
SQL Agent job error:
Executed as user: NT SERVICE\SQLSERVERAGENT. Cannot initialize the data source object of OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "UPLOAD_G". [SQLSTATE 42000] (Error 7303) OLE DB provider "Microsoft.ACE.OLEDB.12.0" for linked server "UPLOAD_G" returned message "Unspecified error". [SQLSTATE 01000] (Error 7412). The step failed.
I'm thinking it's a permission issue, and I've searched and Googled for 2 days but I just cannot figure out how to fix it. I'm not sure if the problem is at the file system level or the Linked Server security settings.
I would greatly appreciate any help someone can offer! This seems like it should be so straight-forward but it's not at all. I am meeting with the client next week for project "wrap up" but I can't seem to get over this hurdle and really need to.
Thanks!
March 16, 2018 at 1:06 pm
I stumbled on the fix and want to share it here for others who come along with the same problem.
Apparently, because my linked server is to an Excel file via the OLE DB provider "Microsoft.ACE.OLEDB.12.0," the remote login setup in the Linked Server's security window has to be "admin" with no password.
Here are the exact things I changed and got my stored proc to actually load the Excel data to a SQL table from a SQL Agent job...
March 12, 2019 at 8:14 am
Thanks for this solution!
This solved my problem after searching for a long while.
Some small addition in case you want to run a report in SSRS wich runs a Stored Procedure which executes a SQL Job:
in the [System Databases > msdb > Security > Users] give the user mentioned the TargetServersRole and under Securables, add the 'sp_start_job' and 'sp_stop_job' and grant them Execute permissions.
This way your user is allowed to run a Stored Procedure.
Now you can run the Stored Procedure from within SSRS that is linked to a Linked Server (i.e. Excel File).
CREATE Procedure [dbo].[SP] (...)
AS
EXEC msdb.dbo.sp_start_job N'ExactJobName' ;
....
June 26, 2019 at 4:55 pm
Hi ,
I am facing similar kind of issue.
I wanted to schedule a job which basically fetches data from JSON API and dumps into the table.
T-SQL store procedure works perfectly. However, when I try to execute a store procedure as a job, the job runs but It does not populate data. I am using sp_oaMethod, so_oaCreate and sp_oaDestroy system store procedure to achieve that.
Now, I tried everything like checking permission of SQL SERVER agent account, giving permissions to system store procedure (mentioned as above). The thing is job is not even failing, It runs without giving any results.
All other jobs uses same SQL server agent account and runs fine. (These jobs does not involve accessing JSON API though).
I also discussed same issue in MSDN SQL Server Support Site. But, I did not get any solution.
Please give your suggestions.
June 26, 2019 at 6:22 pm
Create a proxy account that has the necessary rights/permissions to perform this function. Permissions need to be defined in SQL Server and the file system - and a proxy account will need to be a windows account.
Once you have the proxy account setup and added to the appropriate agent subsystem - then set that job step to run as the proxy account.
For the original post - this would have solved the problem without having to change the ownership of the job. The proxy account would be utilized for that job step.
Jeffrey Williams
“We are all faced with a series of great opportunities brilliantly disguised as impossible situations.”
― Charles R. Swindoll
How to post questions to get better answers faster
Managing Transaction Logs
June 26, 2019 at 8:05 pm
Hi Jeffery,
Thanks for your reply. (Just so you know, I already have sysadmin privileges for my account)
I am using simple T-SQL statement Exec Sp in my job step.
I do not see T-sql option under the subsystem while creating proxy.
What should I select?
June 27, 2019 at 6:21 pm
You are correct - the proxy account would not work for T-SQL agent jobs.
Jeffrey Williams
“We are all faced with a series of great opportunities brilliantly disguised as impossible situations.”
― Charles R. Swindoll
How to post questions to get better answers faster
Managing Transaction Logs
July 2, 2019 at 1:06 pm
Hi,
Then, how to resolve this problem?
Thanks,
Jinal.
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply