Create a linked server in SQL 2025 connecting to a SQL 2017 Instance

Thomas E Rozzi 0 Reputation points
2026-11-13T19:02:31.75+00:00

Hi-

I currently have a linked server on a SQL 2019 Sql Server Instance connecting to a SQL 2017 instance using provider SQLCLNI11 which has been deprecated.

I need to migrate the Linked Server to a SQL 2025 Instance connecting to the same SQL 2017 Instance.

Thanks

Thomas

SQL Server Database Engine

2 answers

Sort by: Most helpful
  1. Erland Sommarskog 137.7K Reputation points MVP Volunteer Moderator
    2026-11-13T19:42:05.3766667+00:00

    Things are a little different with SQL 2025, since it is now using the MSOLEDBSQL19 provider, which defaults to require an encrypted connection. (Just like all other client APIs from Microsoft.) This can be tackled in more than one way. One is to install a proper certificate on the SQL 2017 instance and which is trusted on SQL 2025 instance. This can be a certificate that you buy from a provider whose root certificate in the trusted certificate store on SQL 2025 - and quite a few vendor's root certificates comes with Windows. You can also create a self-signed certificate that you distribute yourself, see this article for how to do this: https://codekabinett.com/rdumps.php?Lang=2&targetDoc=create-install-ssl-tls-certificate-sql-server. (Note that this discussion is by no means specific to linked servers, but it applies to all connections to SQL Server, no matter they are from SSMS, applications or other SQL Server instances.)

    If you follow this path, you create the linked server in the same way as before, for instance:

    EXEC sp_addlinkedserver 'MYSERVER'
    

    If you are not worried about man-in-the-middle attacks, you can opt to trust the self-signed certificate that SQL Server creates when it starts up. In this case, you need to cater for this when you create the linked server:

    EXEC sp_addlinkedserver 'MYSERVER', '', 'MSOLEDBSQL19', @datasrc = 'MYSERVER', @provstr = 'TrustServerCertificate=yes'
    

    Note here that the first MYSERVER is the alias that you will use locally for the linked server, whereas the argument to @datasrc is the actual network name for the server, which may include instance name (or port number). That is, they do not have to be the same.

    However, the error message you get suggests some different issue, which may be related to the communication with the AD, but set up the linked server with trust for the certificate first, before we dig into deeper troubleshooting.

    Was this answer helpful?


  2. AI answer

    2026-11-13T19:03:32.5466667+00:00

    Replace SQLNCLI11 with MSOLEDBSQL and explicitly set encryption when recreating the linked server on SQL Server 2025.

    SQL Server 2025 uses Microsoft OLE DB Driver 19 for MSOLEDBSQL. Unlike the old provider, it requires an Encrypt value; without one, it defaults to mandatory encryption and the connection fails unless SQL Server 2017 presents a valid trusted certificate.^1^

    Create the linked server

    For production, use Encrypt=Mandatory and configure the SQL Server 2017 instance with a CA-signed certificate whose name matches the server FQDN:

    USE master;
    GO
    
    EXEC sys.sp_addlinkedserver
        @server     = N'SQL2017_LINK',
        @srvproduct = N'',
        @provider   = N'MSOLEDBSQL',
        @datasrc    = N'SQL2017Server\InstanceName',
        @provstr    = N'Encrypt=Mandatory;';
    GO
    

    Encrypt=Mandatory requires a trusted CA-signed certificate; a self-signed certificate is not accepted by default.^2^

    If the SQL Server 2017 instance does not currently have a trusted certificate, use this compatibility configuration while planning the certificate deployment:

    EXEC sys.sp_addlinkedserver
        @server     = N'SQL2017_LINK',
        @srvproduct = N'',
        @provider   = N'MSOLEDBSQL',
        @datasrc    = N'SQL2017Server\InstanceName',
        @provstr    = N'Encrypt=Optional;';
    GO
    

    Encrypt=Optional does not require a certificate, but the linked-server traffic is not encrypted. Avoid TrustServerCertificate=Yes as a production workaround because it disables certificate validation and also requires the corresponding client registry setting.^1^

    Configure authentication

    Choose one mapping model.

    Windows credential delegation:

    EXEC sys.sp_addlinkedsrvlogin
        @rmtsrvname = N'SQL2017_LINK',
        @locallogin = NULL,
        @useself     = N'True';
    GO
    

    This passes the caller’s Windows security context. For remote clients, Kerberos delegation must be configured; otherwise, the common “double-hop” authentication issue can prevent access.

    Dedicated SQL Server login:

    EXEC sys.sp_addlinkedsrvlogin
        @rmtsrvname = N'SQL2017_LINK',
        @locallogin = NULL,
        @useself     = N'False',
        @rmtuser     = N'LinkedServerLogin',
        @rmtpassword = N'<strong-password>';
    GO
    

    With @locallogin = NULL, the mapping applies to all local logins. For tighter security, replace NULL with a specific local login and grant the remote login only the required permissions.^3^

    Be aware that scripted SQL credentials can be exposed in saved scripts, backups, or logs; do not use an administrator account.

    Test the migration

    Run the test under the same local login or SQL Agent execution context that will use the linked server:

    EXEC sys.sp_testlinkedserver
        @servername = N'SQL2017_LINK';
    GO
    
    SELECT name
    FROM [SQL2017_LINK].[master].[sys].[databases];
    GO
    

    sp_testlinkedserver raises the underlying connection or authentication error when the test fails, and its caller must have an applicable login mapping.^4^

    SSMS alternative

    In SSMS:

    1. Connect to SQL Server 2025.
    2. Open Server Objects → Linked Servers.
    3. Right-click Linked Servers → New Linked Server.
    4. Select Other data source.
    5. Set:
      • Provider: Microsoft OLE DB Driver for SQL Server
      • Product name: leave blank
      • Data source: SQL2017Server\InstanceName
      • Provider string: Encrypt=Mandatory; or Encrypt=Optional;
    6. Configure the mapping on the Security page.
    7. Right-click the resulting linked server and select Test Connection.

    Do not reinstall or continue using SQLNCLI11: SQL Server Native Client was removed from SQL Server 2022 and later and is not recommended for new development. MSOLEDBSQL19/MSOLEDBSQL is the supported current provider family.^5^


    References

    1. Linked servers (Database Engine)
    2. sys.sp_addlinkedserver (Transact-SQL)
    3. sys.sp_addlinkedsrvlogin (Transact-SQL)
    4. sp_testlinkedserver (Transact-SQL)
    5. Microsoft OLE DB Driver for SQL Server
    AI-generated content may be incorrect. Read our transparency notes for more information.

    Was this answer helpful?

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.