Blog Post

SQL Server Support Blog
2 MIN READ

Generic ODBC external data sources may not work after installing Cumulative Update

NathanMSFT's avatar
NathanMSFT
Icon for Microsoft rankMicrosoft
Mar 30, 2023

Symptoms

 

After you install SQL Server 2019 CU19 or SQL Server 2022 CU2, external data sources using generic ODBC connector may no longer work. When you try to query external tables that were created before installing the cumulative update, you receive the following error message:

 

Msg 7320, Level 16, State 110, Line 68

Cannot execute the query "Remote Query" against OLE DB provider "MSOLEDBSQL" for linked server "(null)". Object reference not set to an instance of an object.

 

If you try to create a new external table, you receive the following error message:

 

Msg 110813, Level 16, State 1, Line 64

Object reference not set to an instance of an object.

 

Cause

The issue occurs if the Driver keyword isn't specified in the CONNECTION_OPTIONS argument of the EXTERNAL DATA SOURCE definition. This issue was introduced due to a code change that was released in SQL Server 2019 CU19 and SQL Server 2022 CU2.

 

Workaround

You can uninstall SQL Server 2019 CU19 or SQL Server 2022 CU2 to work around this issue. Or, if you create a new external data source and only reference the DSN keyword, add the Driver keyword to the CONNECTION_OPTIONS argument. You can add anything in the Driver key-value pair (KVP) because the DSN definition will override whatever is specified in the Driver KVP.

 

For example, if you create a new external data source as follows:

 

CREATE EXTERNAL DATA SOURCE MyExternalDataSource

WITH

       ( LOCATION = 'odbc://{server}:port'

         , CREDENTIAL = MyCredential

         , PUSHDOWN = ON

         , CONNECTION_OPTIONS = 'DSN=MyDSN'

       );

 

You can add the Driver keyword to the CONNECTION_OPTIONS argument. Separate the KVPs with a semi-colon.

 

CREATE EXTERNAL DATA SOURCE MyExternalDataSource

WITH

       ( LOCATION = 'odbc://{server}:port'

         , CREDENTIAL = MyCredential

         , PUSHDOWN = ON

         , CONNECTION_OPTIONS = 'DSN=MyDSN;Driver=LiterallyAnyString'

       );

 

If you have an existing external data source that is no longer working after installing the cumulative update, you can use ALTER EXTERNAL DATA SOURCE and reset the CONNECTION_OPTIONS argument to add the Driver keyword. For example, if the existing external data source was defined as follows:

 

CREATE EXTERNAL DATA SOURCE MyAlreadyExistingExternalDataSource

WITH

       ( LOCATION = 'odbc://{server}:port'

         , CREDENTIAL = MyCredential

         , PUSHDOWN = ON

         , CONNECTION_OPTIONS = 'DSN=MyDSN'

       );

 

You can add the Driver keyword to the existing CONNECTION_OPTIONS argument. Separate the KVPs with a semi-colon.

 

ALTER EXTERNAL DATA SOURCE MyAlreadyExistingExternalDataSource SET CONNECTION_OPTIONS = 'DSN=MyDSN;Driver=LiterallyAnyString'

 

If you don't know what connection options are set, check the connection_options column in the sys.external_data_sources system catalog view. If you script out the external data sources, it won't show the CONNECTION_OPTIONS argument correctly.

 

Status

Microsoft is working on a fix for this issue that will be available in a future CU.

Published Mar 30, 2023
Version 1.0
  • JeffShervey's avatar
    JeffShervey
    Copper Contributor

    So I can check if I have any ODBC external sources created by querying this table in my instance:

    select * from sys.external_data_sources;

    That true?

     

     

     

  • Yes, Jeff, you can check that table and check for any entries in the location column that start with 'odbc://'. Those would be your generic ODBC external data sources.

  • Berch1108's avatar
    Berch1108
    Copper Contributor

    We recently installed CU19 for our SQL 2019 (on Windows 2022). When we were trying uninstall CU19, it is prompting for the installation media. I am afraid that will not make any harm to the SQL server. I haven't experienced this type of behaviour when uninstalling patches. Appreciate if you could advise. 

  • Hi Berch1108,

     

    I have seen prompting for installation media when uninstalling cumulative updates - that is nothing to be alarmed about. Just be sure that you're uninstalling the update for SQL Server 2019 and not the entire product. When you go to Control Panel > Program Files, be sure to click on the 'View installed updates' link in the upper left and choose the hotfix associated with CU19 (Hotfix 4298).

     

    I don't always see a prompt for installation media when uninstalling a CU, but it is common to see. I don't know why you are sometimes prompted for the installation media or not. 

  • thanks for the details. can you give an example for ODBC and OLEDB what to put on "LiterallyAnyString"

    'DSN=MyDSN;Driver=LiterallyAnyString'

  • Reinaldo - you can put literally anything in that string. It doesn't matter. You could put Driver=blah or Driver=Reinaldo. Literally anything. There just needs to be an entry for Driver key-value pair in the CONNECTION_OPTIONS. 

  • Anne_Ca's avatar
    Anne_Ca
    Copper Contributor

    Hi, I checked in our table select * from sys.external_data_sources; we don't have any records.

    Also I know we did not create any external data resource.

    But we do have some SSIS packages that uses connection manager that uses ODBC, or OLEDB driver for data source or destination for data flow tasks, will this update break those?

     

    Thanks, 

  • Hi Anne_Ca,

     

    This issue only affects Data Virtualization (PolyBase) ODBC connector functionality. SSIS or ODBC/OLEDB drivers in general are unaffected.