sql-server-2008-r2oracle10glinked-serverora-12170

Connect timeout occurred in sql server with linked server


I Connected to Oracle as Linked Server from Sql Server 2008 R2 after Executing 20-30 Min i getting following error:

    OLE DB provider "OraOLEDB.Oracle" for linked server "CBSLINKED"
 returned message "ORA-12170: TNS:Connect timeout occurred".
    Cannot initialize the data source object of OLE DB provider
 "OraOLEDB.Oracle" for linked server "CBSLINKED".

Script:

set @query = '   
      INSERT INTO dbo.tbl_MyTable  
 (  
  AccNo,  
  BranchCode,  
  BranchName,  
  CustomerName,  
  ScanDate,  
  TranCount,  
  TranAmount,  
  AccType  
 )    
   select AccNo,BranchCode,BranchName,LongName,  
  '''+CONVERT(CHAR(10),@RunningDate,111 )+'''   
   ,TranCount,TranAmount,AccType  

  from OPENQUERY(CBSLINKED,''select TBM.AC as AccNo,  
      TBM.BC as BranchCode ,CM.CNM, COUNT(*) TranCount,    
  SUM(TBM.AMT) TranAmount, TBM.AH  as AccType,CM.CNM as LongName  
     ,BM.BR_NM as BranchName  
     from BKP.T_2014 TBM  
     LEFT OUTER JOIN BKP.ACMST AM  
     ON TBM.AC=AM.AC   and TBM.BC=AM.BC  
     and TBM.AH=AM.AH  
     LEFT OUTER JOIN BKP.BCMST  BM  
     ON TBM.BC=BM.BC  
     LEFT OUTER JOIN BKP.CLMST CM  
     ON TBM.CN=CM.CNO  
   where    TBM.AMT>=''''' +CONVERT(CHAR(50),@MinAmt,111)+ ''''' and
   CM.CNM NOT LIKE ''''CENTRALISE%'''' and  
   TBM.NR NOT LIKE ''''%Del%'''' and  
      CAST(TBM.DT as DATE) = '''''+CONVERT(CHAR(10),@RunningDate,111 )+'''''   
   AND TBM.DC= ''''D''''   
    AND (TC=''''CP'''' OR TC=''''CR'''')  
    GROUP BY  
  TBM.BC,TBM.AH,  
  TBM.AC,CM.CNM,BM.BR_NM  
   '')where AccType IN (select AccTypeCode from  tbl_ACCMAST where AccType IN (  
  select distinct AccType from RuleMaster where RuleID=6))  
     '  
   print @query  
  execute sp_executesql @query 

and

 My <code>sp_configure</code> values Use Control+Mouse Scroll to enlarge image


Solution

  • I configured two things and its works for me

    1. Set Remote Query Timeout to infinite

    sp_configure 'remote query timeout', 0  
    go  
    reconfigure with override  
    go
    

    2. Set Remote Login Timeout to 2147483647

    sp_configure 'remote login timeout (s)', 2147483647
    go
    reconfigure with override
    go