Blog Post

SQL Server Blog
1 MIN READ

Released: Update to Microsoft OLE DB Driver 18 for SQL Server

David-Engel's avatar
David-Engel
Iron Contributor
May 16, 2019
Microsoft OLE DB Driver 18.2.2 for SQL Server was released this week to fix an issue related to Azure Active Directory authentication.

 

Fixed:

  • The OLE DB Driver 18.2.1 incorrectly tries to change the COM concurrency model on an apartment that was previously initialized as multi-threaded (MTA). As a result, in an application that makes more than one subsequent call to CoInitialize or CoInitializeEx prior to calling the IDBInitialize::Initialize interface, the driver fails to connect when using any of the Azure Active Directory authentication modes.
The updated driver can be downloaded directly from Microsoft.

David Engel
Updated Feb 19, 2020
Version 2.0

5 Comments

  • jluebbers's avatar
    jluebbers
    Copper Contributor

    We have tested this between a few different versions of SQL Server, all running on Windows Server 2016 (with current updates installed) and MSOLEDBSQL driver 18.2.2.0 installed:

     

    *** ISSUE PRESENT - MS DTC ERROR ON SELECT ***
    Local Server: Microsoft SQL Server 2014 (SP3-CU3) (KB4491539) - 12.0.6259.0
    Remote Server: Microsoft SQL Server 2014 (SP3-CU2) (KB4482960) - 12.0.6214.1

     

    *** ISSUE PRESENT - MS DTC ERROR ON SELECT ***
    Local Server: Microsoft SQL Server 2014 (SP3-CU3) (KB4491539) - 12.0.6259.0
    Remote Server: Microsoft SQL Server 2017 (RTM-CU15-GDR) (KB4505225) - 14.0.3192.2

     

    *** NO ISSUE - SELECT WORKS NORMALLY ***
    Local Server: Microsoft SQL Server 2017 (RTM-CU15-GDR) (KB4505225) - 14.0.3192.2
    Remote Server: Microsoft SQL Server 2014 (SP3-CU3) (KB4491539) - 12.0.6259.0

     

    *** NO ISSUE - SELECT WORKS NORMALLY ***
    Local Server: Microsoft SQL Server 2017 (RTM-CU15-GDR) (KB4505225) - 14.0.3192.2
    Remote Server: Microsoft SQL Server 2017 (RTM-CU15-GDR) (KB4505225) - 14.0.3192.2

     

    It seems that the bug is present when the driver is used from a linked server on a SQL Server 2014 instance. The other way around seems fine - if the local server is SQL Server 2017 the bug isn't present.

  • jluebbers's avatar
    jluebbers
    Copper Contributor

    David-Engel repro script pasted here, hopefully this doesn't get eaten by the comments form:

     

     

    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO

    USE [master]
    GO

    EXEC master.dbo.sp_addlinkedserver @server = N'MyLinkedServer', @srvproduct=N'', @provider=N'MSOLEDBSQL', @provstr=N'Server=remoteinstance.mydomain.local;MultiSubnetFailover=Yes;'
    GO

    EXEC master.dbo.sp_addlinkedsrvlogin @rmtsrvname=N'MyLinkedServer',@useself=N'True',@locallogin=NULL,@rmtuser=NULL,@rmtpassword=NULL
    GO

    EXEC master.dbo.sp_serveroption @server=N'MyLinkedServer', @optname=N'collation compatible', @optvalue=N'true'
    GO

    EXEC master.dbo.sp_serveroption @server=N'MyLinkedServer', @optname=N'data access', @optvalue=N'true'
    GO

    EXEC master.dbo.sp_serveroption @server=N'MyLinkedServer', @optname=N'dist', @optvalue=N'false'
    GO

    EXEC master.dbo.sp_serveroption @server=N'MyLinkedServer', @optname=N'pub', @optvalue=N'false'
    GO

    EXEC master.dbo.sp_serveroption @server=N'MyLinkedServer', @optname=N'rpc', @optvalue=N'true'
    GO

    EXEC master.dbo.sp_serveroption @server=N'MyLinkedServer', @optname=N'rpc out', @optvalue=N'true'
    GO

    EXEC master.dbo.sp_serveroption @server=N'MyLinkedServer', @optname=N'sub', @optvalue=N'false'
    GO

    EXEC master.dbo.sp_serveroption @server=N'MyLinkedServer', @optname=N'connect timeout', @optvalue=N'0'
    GO

    EXEC master.dbo.sp_serveroption @server=N'MyLinkedServer', @optname=N'collation name', @optvalue=null
    GO

    EXEC master.dbo.sp_serveroption @server=N'MyLinkedServer', @optname=N'lazy schema validation', @optvalue=N'false'
    GO

    EXEC master.dbo.sp_serveroption @server=N'MyLinkedServer', @optname=N'query timeout', @optvalue=N'0'
    GO

    EXEC master.dbo.sp_serveroption @server=N'MyLinkedServer', @optname=N'use remote collation', @optvalue=N'true'
    GO

    EXEC master.dbo.sp_serveroption @server=N'MyLinkedServer', @optname=N'remote proc transaction promotion', @optvalue=N'true'
    GO


    /*
    this fails with:

    Msg 8522, Level 16, State 3, Line 50
    Microsoft Distributed Transaction Coordinator (MS DTC) has stopped this transaction.
    */
    SELECT TOP 10
    *
    FROM [MyLinkedServer].[master].[sys].[databases]
    GO

     

    /*
    this succeeds
    */
    BEGIN DISTRIBUTED TRANSACTION
    SELECT TOP 10
    *
    FROM [MyLinkedServer].[master].[sys].[databases]
    COMMIT TRANSACTION
    GO

     

  • jluebbers's avatar
    jluebbers
    Copper Contributor

    David-Engel  Thanks - there doesn't seem to be a way to attach files here in the comments so I've tried to upload a repro script in the Azure feedback forum I linked above. My comments there are awaiting moderator approval so I'll repeat them here:

     

    Repro script attached. We have tested this between a few different versions of SQL Server, all running on Windows Server 2016 (with current updates installed) and MSOLEDBSQL driver 18.2.2.0 installed:

     

    *** ISSUE PRESENT - MS DTC ERROR ON SELECT ***
    Local Server: Microsoft SQL Server 2014 (SP3-CU3) (KB4491539) - 12.0.6259.0
    Remote Server: Microsoft SQL Server 2014 (SP3-CU2) (KB4482960) - 12.0.6214.1

     

    *** ISSUE PRESENT - MS DTC ERROR ON SELECT ***

    Local Server: Microsoft SQL Server 2014 (SP3-CU3) (KB4491539) - 12.0.6259.0
    Remote Server: Microsoft SQL Server 2017 (RTM-CU15-GDR) (KB4505225) - 14.0.3192.2

     

    *** NO ISSUE - SELECT WORKS NORMALLY ***
    Local Server: Microsoft SQL Server 2017 (RTM-CU15-GDR) (KB4505225) - 14.0.3192.2
    Remote Server: Microsoft SQL Server 2014 (SP3-CU3) (KB4491539) - 12.0.6259.0

     

    *** NO ISSUE - SELECT WORKS NORMALLY ***
    Local Server: Microsoft SQL Server 2017 (RTM-CU15-GDR) (KB4505225) - 14.0.3192.2
    Remote Server: Microsoft SQL Server 2017 (RTM-CU15-GDR) (KB4505225) - 14.0.3192.2

     

    It seems that the bug is present when the driver is used from a linked server on a SQL Server 2014 instance. The other way around seems fine - if the local server is SQL Server 2017 the bug isn't present.

  • David-Engel's avatar
    David-Engel
    Iron Contributor

    jluebbers You would need to contact MS support and they would file an issue. However, a customer just bubbled this up to our attention last week. We are waiting for more information to reproduce the issue. For reference, select * from server.master.sys.databases works fine for me using version 18.2.1 of the driver and SQL Server 2017 CU 17. If you have a linked server creation script and version details which repro the issue, I'd be happy to forward it on to the team.

     

    David

  • jluebbers's avatar
    jluebbers
    Copper Contributor

    What's the correct channel for reporting bugs with the MSOLEDBSQL driver? This SQL Server feedback item has been open since Sep 2018 but I'm not sure whether it's got back to the team responsible for that driver.

     

    https://feedback.azure.com/forums/908035-sql-server/suggestions/35400568-msoledbsql

     

    This issue affects SQL Server linked servers that use this driver - simple SELECTs from a remote table/view using such a linked server fail with "Microsoft Distributed Transaction Coordinator (MS DTC) has stopped this transaction." unless you first begin an explicit distributed transaction. The issue doesn't seem to affect INSERTs/UPDATEs/DELETEs to a remote table or EXECing a remote proc strangely, which work fine without the explicit distributed transaction. The issue is not present in linked servers that use the older SQLNCLI11 or SQLOLEDB drivers. Repro'ed with versions 18.2.1 and 18.2.2 of MSOLEDBSQL.