none
SQL Server Linked Server stays connected locally RRS feed

  • Question

  • I am trying to create a linked server within XXXXX-02 database server so that it could communicate with the XXXXX-01 database server.

    I do follow instructions, I do specify the remote server parameters, I do get a good connection, but no matter what I do, the linked server stays connected locally, only sees local tables, doesn't see the tables in the remote database.

    I am at a stand still as no matter how explicitly I specify the remote server XXXXX-01, the connection properties of the linked server keep specifying the local server XXXXXX-02.

    How can I change my script or settings to connect to the remote server

    Here is the script to create linked server for XXXXXX-01

    USE [master]
    GO
    
    /****** Object:  LinkedServer [XXXXXXX-01]    Script Date: 11/5/2019 12:18:47 PM ******/
    EXEC master.dbo.sp_dropserver @server=N'XXXXXXX-01', @droplogins='droplogins'
    GO
    
    /****** Object:  LinkedServer [XXXXXXX-01]    Script Date: 11/5/2019 12:18:48 PM ******/
    EXEC master.dbo.sp_addlinkedserver @server = N'XXXXXXX-01', @srvproduct=N'SQL Server'
     /* For security reasons the linked server remote logins password is changed with ######## */
    EXEC master.dbo.sp_addlinkedsrvlogin @rmtsrvname=N'XXXXXXX-01',@useself=N'False',@locallogin=NULL,@rmtuser=NULL,@rmtpassword=NULL
    EXEC master.dbo.sp_addlinkedsrvlogin @rmtsrvname=N'XXXXXXX-01',@useself=N'True',@locallogin=N'ACCESS_SQL',@rmtuser=NULL,@rmtpassword=NULL
    GO
    
    EXEC master.dbo.sp_serveroption @server=N'XXXXXXX-01', @optname=N'collation compatible', @optvalue=N'false'
    GO
    
    EXEC master.dbo.sp_serveroption @server=N'XXXXXXX-01', @optname=N'data access', @optvalue=N'true'
    GO
    
    EXEC master.dbo.sp_serveroption @server=N'XXXXXXX-01', @optname=N'dist', @optvalue=N'false'
    GO
    
    EXEC master.dbo.sp_serveroption @server=N'XXXXXXX-01', @optname=N'pub', @optvalue=N'false'
    GO
    
    EXEC master.dbo.sp_serveroption @server=N'XXXXXXX-01', @optname=N'rpc', @optvalue=N'false'
    GO
    
    EXEC master.dbo.sp_serveroption @server=N'XXXXXXX-01', @optname=N'rpc out', @optvalue=N'false'
    GO
    
    EXEC master.dbo.sp_serveroption @server=N'XXXXXXX-01', @optname=N'sub', @optvalue=N'false'
    GO
    
    EXEC master.dbo.sp_serveroption @server=N'XXXXXXX-01', @optname=N'connect timeout', @optvalue=N'0'
    GO
    
    EXEC master.dbo.sp_serveroption @server=N'XXXXXXX-01', @optname=N'collation name', @optvalue=null
    GO
    
    EXEC master.dbo.sp_serveroption @server=N'XXXXXXX-01', @optname=N'lazy schema validation', @optvalue=N'false'
    GO
    
    EXEC master.dbo.sp_serveroption @server=N'XXXXXXX-01', @optname=N'query timeout', @optvalue=N'0'
    GO
    
    EXEC master.dbo.sp_serveroption @server=N'XXXXXXX-01', @optname=N'use remote collation', @optvalue=N'true'
    GO
    
    EXEC master.dbo.sp_serveroption @server=N'XXXXXXX-01', @optname=N'remote proc transaction promotion', @optvalue=N'true'
    GO
    
    
    

    Here is the screenshot with connection properties



    Tuesday, November 5, 2019 6:01 PM

All replies

  • Tuesday, November 5, 2019 6:15 PM
  • Hi James Scourange

     

    Please try to change the @useself  in your script:

    EXEC master.dbo.sp_addlinkedsrvlogin @rmtsrvname=N'XXXXXXX-01',@useself=N'False',@locallogin=NULL,@rmtuser=NULL,@rmtpassword=NULL EXEC master.dbo.sp_addlinkedsrvlogin @rmtsrvname=N'XXXXXXX-01',@useself=N'False',@locallogin=N'ACCESS_SQL',@rmtuser=NULL,@rmtpassword=NULL GO

     

    Best regards,

    Dedmon Dai


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com

    Wednesday, November 6, 2019 9:14 AM
  • Dedmon, thank you very much for your suggestion, I did try it

    Here is what I got after I tried to run SELECT against the linked server

    OLE DB provider "SQLNCLI11" for linked server "XXXXXX-01" returned message "Invalid authorization specification".
    Msg 7399, Level 16, State 1, Line 1
    The OLE DB provider "SQLNCLI11" for linked server "XXXXXX-01" reported an error. Authentication failed.
    Msg 7303, Level 16, State 1, Line 1
    Cannot initialize the data source object of OLE DB provider "SQLNCLI11" for linked server "XXXXXX01"

    Is there something else I need to change?

    Thank you again

    Wednesday, November 6, 2019 5:27 PM
  • Hi James Scourange

     

    Would you please try to use sp_testlinkedserver N'xxxxxx-01' for testing linked server ? If you get the same error?

     

    Delete EXEC master.dbo.sp_addlinkedsrvlogin @rmtsrvname=N'XXXXXXX-01',@useself=N'False',@locallogin=NULL,@rmtuser=NULL,@rmtpassword=NULL in your script and use

    EXEC master.dbo.sp_addlinkedsrvlogin @rmtsrvname=N'XXXXXXX-01',@useself=N'False',@locallogin=N'ACCESS_SQL',@rmtuser=NULL,@rmtpassword=NULL
    GO only.

     

    For more details, please refer to https://blog.sqlauthority.com/2015/10/03/sql-server-linked-server-creation-error-ole-db-provider-sqlncli11-for-linked-server-returned-message-invalid-authorization-specification/

     

    Best regards,

    Dedmon Dai


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com

    Thursday, November 7, 2019 2:54 AM