Sql error 7412

I have a sql agent job executing on ServerA, one of the steps executes a stored procedure in ServerA.DatabaseA. The stored procedure then reaches across the wire to ServerB via a linked server, and tries to select data from ServerB.DatabaseB.SchemaB.TableB. When it does this I get the following error message:
  • Remove From My Forums
  • Вопрос

  • I have a sql agent job executing on ServerA, one of the steps executes a stored procedure in ServerA.DatabaseA. The stored procedure then reaches across the wire to ServerB via a linked server, and tries to select data from ServerB.DatabaseB.SchemaB.TableB.
    When it does this I get the following error message:

    Message

    Executed as user: <domain><user>. Named Pipes Provider: Could not open a connection to SQL Server [1450]. [SQLSTATE 42000] (Error 1450)  OLE DB provider «SQLNCLI» for linked server «ServerB» returned message «Login timeout expired». [SQLSTATE
    01000] (Error 7412)  OLE DB provider «SQLNCLI» for linked server «<remote server>» returned message «An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact
    that under the default settings SQL Server does not allow remote connections.». [SQLSTATE 01000] (Error 7412).  The step failed.

    Anybody have any ideas?

    ServerA: Microsoft SQL Server 2005 — 9.00.4035.00 (X64)   Nov 24 2008 16:17:31   Copyright (c) 1988-2005 Microsoft Corporation  Enterprise Edition (64-bit) on Windows NT 5.2 (Build 3790: Service Pack 2) 

    ServerB: Microsoft SQL Server 2005 — 9.00.5000.00 (X64)   Dec 10 2010 10:38:40   Copyright (c) 1988-2005 Microsoft Corporation  Enterprise Edition (64-bit) on Windows NT 5.2 (Build 3790: Service Pack 2) 

    Wayne E. Pfeffer

Ответы

  • In order to get a scenario such as yours to work in my test environment, I configured everything as per
    Case 3 in the link previously provided.

    • Create a SQL Server Login, with NON-SYSADMIN rights i.e. just the rights required to execute the procedure on Server A.
    • Make the SQL Server Login the «Owner» (not RunAs, that is for proxy Accounts) of the SQL Server Agent job.
    • Create a SQL Server Login with the same name on Server B that has access to the tables/objects referenced in the procedure on Server A.
    • Map the SQL Server Login from Server A to Server B in the Linked Server Connection configuration and test independently of the SQL Server Agent job to validate security and access.
    • Now run via the SQL Server Agent job on Server A.

    John Sansom |
    SQL Server DBA Blog | Twitter

    • Помечено в качестве ответа

      28 февраля 2011 г. 17:44

I am using SQL Server 2012. I have scheduled a job to run every 1 hour, with 1 step calling 1 simple Stored Procedure. The Stored Procedure migrates around 1K data from production server to our local server. Linked server has been established successfully. The query used in Stored procedure looks like below.

SELECT ID,Col1,Col2,Col3,Col4,Col5 into #temp from [111.111.111.111].ProdServer.dbo.SourceTable

Insert into Localtable(ID,Col1,Col2,Col3,Col4,Col5)
SELECT ID,Col1,Col2,Col3,Col4,Col5
FROM #temp where ID NOT IN (select ID from Localtable)

enter image description here

The job execution sometimes takes 25-30 secs which will successfully executed. Sometimes it takes 48-50 seconds which results in failure. Please refer failure message below and other details in above screenshot.

Failure Message:

Executed as user: NT AUTHORITYNETWORK SERVICE. Named Pipes Provider: Could not open a connection to SQL Server [53]. [SQLSTATE 42000] (Error 53) OLE DB provider «SQLNCLI10» for linked server «111.111.111.111» returned message «Login timeout expired». [SQLSTATE 01000] (Error 7412) OLE DB provider «SQLNCLI10» for linked server «111.111.111.111» returned message «A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online.». [SQLSTATE 01000] (Error 7412). The step failed.

More Details

  • The table is locked by nobody and no queries run on it.
  • In Linked Server Properties, both Query Timeout and Connection Timeout
    has been set to 0.
  • In Server properties remote query Timeout is also set to 600 Secs.

As last option I tried to change Connection Timeout Settings from its default value 15 to 6000 or higher. I could not achieve it. Please suggest solution to execute my scheduled jobs successfully even it takes 48 minutes or slight more.

Right Click on server > Click on properties > Click view connection properties on left pane under connection — to see Connection Timeout Property

1 new observation:
The job is failing if it takes 48 seconds or more to run.

troubleshoot sql server mail problem

How to fix this issue?

Here is error message:

Date  4/21/2014 6:40:00 AM
Log  Job History (Email Notification)

Step ID  1
Server  testabc
Job Name  Email Notification
Step Name  sp99_email_process
Duration  00:00:01
Sql Severity 16
Sql Message ID 17925
Operator Emailed 
Operator Net sent 
Operator Paged 
Retries Attempted 0

Message
Executed as user: tuabc . xp_sendmail: failed with mail error 0x8004060c [SQLSTATE 42000] (Error 17925).  The step failed.

April 21st, 2014 8:33am


This is from sql server 2005 sp2.

Any specific help?

April 21st, 2014 10:13am


Please post the database mail log, otherwise it’s just guessing in the dark.

April 21st, 2014 10:19am


Here is error log:

Date  4/21/2014 6:30:00 AM
Log  Job History (Email Notification)

Step ID  1
Server  test

Job Name  Email Notification
Step Name  sp99_email_process
Duration  00:00:46
Sql Severity 16
Sql Message ID 7412
Operator Emailed 
Operator Net sent 
Operator Paged 
Retries Attempted 0

Message
Executed as user: TUABC. SQL Network Interfaces: Error Locating Server/Instance Specified [xFFFFFFFF]. [SQLSTATE 42000] (Error 65535)  OLE DB provider «SQLNCLI» for linked server «TUJohn» returned message «Login timeout expired». [SQLSTATE 01000]
(Error 7412)  OLE DB provider «SQLNCLI» for linked server «TUJohn» returned message «An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default
settings SQL Server does not allow remote connections.». [SQLSTATE 01000] (Error 7412).  The step failed.

April 21st, 2014 11:22am


Hello,

That’s the log from the job, we’re interested in the log for database mail which is held in MSDB. I do want to note that you’re having login issues with that job that should be investigated.

Look at msdb.dbo.sysmail_event_log which should have the reason for mail send failures.

April 21st, 2014 11:33am


I run

select * from msdb.dbo.sysmail_event_log

I find following log:Any help?

log_id event_type log_date description process_id mailitem_id account_id last_mod_date last_mod_user
11853 error 2014-04-21 06:41:01.060 The mail could not be sent to the recipients because of the mail server failure. (Sending Mail using Account 1 (2014-04-21T06:41:01). Exception Message: Cannot send mails to mail server. (The specified string
is not in the form required for an e-mail address.).
) 8568 49460 NULL 2014-04-21 06:41:01.060 sa

April 21st, 2014 12:13pm


Hello,

From the error posted:

Exception Message: Cannot send mails to mail server. (The specified string is not in the form required for an e-mail address.).

Double check your recipient addresses are valid.

April 21st, 2014 12:19pm


Here is error log:

Date  4/21/2014 6:30:00 AM
Log  Job History (Email Notification)

Step ID  1
Server  test

Job Name  Email Notification
Step Name  sp99_email_process
Duration  00:00:46
Sql Severity 16
Sql Message ID 7412
Operator Emailed 
Operator Net sent 
Operator Paged 
Retries Attempted 0

Message
Executed as user: TUABC. SQL Network Interfaces: Error Locating Server/Instance Specified [xFFFFFFFF]. [SQLSTATE 42000] (Error 65535)  OLE DB provider «SQLNCLI» for linked server «TUJohn» returned message «Login timeout expired». [SQLSTATE 01000]
(Error 7412)  OLE DB provider «SQLNCLI» for linked server «TUJohn» returned message «An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default
settings SQL Server does not allow remote connections.». [SQLSTATE 01000] (Error 7412).  The step failed.

Hi bestrongself,

According to your error message, we need to verify if you configure SQL Server Database Mail to send email successfully by using your Windows Live Mail account or your mail account. If yes, then you choose use database mail to send a job fail error message
or others. We need to verify if your job owner account which used does have permissions. Check the job owner and the user being for the Agent service has SQL Server admin rights. Add the dbo_owner role to the Job Owner via SQL Server Management Studio.

There is an similar error about data jobs fail message, you can review the following article.

https://support.software.dell.com/capacity-manager-for-sql-server/kb/51365

There is an example configuring SQL Server Database Mail to send email, you can review the following blog.

http://blogs.msdn.com/b/suhde/archive/2009/07/12/how-to-configure-sql-server-database-mail-to-send-email-using-your-windows-live-mail-account-or-your-gmail-account.aspx

Regards,
Sofiya Li

If you have any feedback on our support, please click here.

April 22nd, 2014 4:46am


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:dataUploadupload_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

  • When I run a query that uses the linked server from SSMS, logged in with my domain acct, it works. 
  • When I run the Stored Proc (SP) that utilizes the linked server from SSMS, it works.


SQL Agent job error: 

Executed as user: NT SERVICESQLSERVERAGENT. 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. 

  • The SQL Server Agent service logs on as NT SERVICESQLSERVERAGENT. Note that I am not able to change it to Local System. I am a contractor and other people have jobs setup on this server that I am not involved in. 
  • The job is owned by a windows authentication account that is in the SQL sysadmin role and a member of the domain Administrators group.
  • In the file system, I’ve added the SQLSERVERAGENT account to have Full Control permissions on the folder D:dataUpload. (—> Is this the same account as NT SERVICESQLSERVERAGENT?? All I could find when adding the folder permissions was SQLSERVERAGENT)
  • I’ve tried to go to WindowsServiceProfilesAppDataLocalTemp and add permissions for SQLSERVERAGENT but the user doesn’t even come up in the list. And I’ve tried changing object types and Location to no avail. Based on my research and googling, I thought since the server is x64, this setting wouldn’t be necessary. I was going to try it anyway out of desperation. 
  • The Security settings in the Linked Server tab are confusing to me, to be honest. I have it set to current login context. I have tried to map local/remote accounts but this is the part that’s murky to me and I deleted the entries I attempted. I tried adding NT SERVICESQLSERVERAGENT as the local account and checked the Impersonate box. Not sure this is correct and I haven’t found much documentation on this particular setting. 
  • RPC and RPC Out on the Linked Server are TRUE
  • The provider’s settings have Allow inprocess and Dynamic parameters enabled.
  • No matter which account I set as the job owner, according to Profiler the login account is always SQLSERVERAGENT. 
  • I’ve tried to change the job step’s ‘Run as User…’ setting but when I browse the available list, not all accounts are shown. Even though my account is SQL sysadmin and a in the domain Administrators group, it’s not listed here. 
  • I ran Profiler with the OLEDB category of events selected. I have these results if they will be useful. I won’t list them here initially in case it clutters this post too much. 

Can anyone help?? I’ve searched the forum and tried what I could find, but some solutions here aren’t detailed enough for me, especially around the Linked Server security settings. I need baby steps for this, if that’s what is causing this problem. i.e., what to select under the ‘local’ list, whether to check ‘impersonate,’ what to use in the remote login boxes… 

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!

SQLFan-933088

Mr or Mrs. 500

Points: 549

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…

  1. The SQL Agent job should be owned by a non-sysadmin account. Seems counter-intuitive, but it seems doing this causes SQL Agent to actually use the local/remote user mappings defined in the Linked Server config (details below). In may case, I used a SQL authentication account that is not a member of the SQL sysadmin role. 
  2. In the Linked Server configuration, under the Security tab, I have selected ‘Be made using the login’s current security context’ selected.
  3. In the Linked Server configuration, under the Security tab, under the heading «Local server login to remote server login mappings:», I clicked Add. For the Local Login value, I entered the name of the SQL authentication account that owns the SQL agent job. The impersonate box is not checked. For remote user, I entered «admin». For remote password, leave it blank. Click OK to save the changes. 

This worked for me. I hope it helps someone else!

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' ;
....

jinal

Grasshopper

Points: 23

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.

Jeffrey Williams

SSC Guru

Points: 90002

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.

jinal

Grasshopper

Points: 23

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?

  • This reply was modified 3 years, 7 months ago by  jinal.

Jeffrey Williams

SSC Guru

Points: 90002

You are correct — the proxy account would not work for T-SQL agent jobs.

jinal

Grasshopper

Points: 23

Hi,

Then, how to resolve this problem?

Thanks,

Jinal.

Понравилась статья? Поделить с друзьями:
  • Sql error 58p01 error could not open file
  • Spn 3225 fmi 10 ошибка двигателя лиаз
  • Spn 1761 fmi 18 камаз ошибка
  • Spn 792 fm1 5 код ошибки
  • Spn 171 fmi 3 камаз ошибка