FIX: Execution fails when a SQL CLR function invokes Transact-SQL statements through impersonation calls in SQL Server 2016 and 2017

Applies to: SQL Server 2017 Developer on WindowsSQL Server 2017 Enterprise on WindowsSQL Server 2017 Enterprise Core on Windows


Consider the following scenario:

  • You have a SQL CLR function in SQL Server 2016 and 2017.
  • The CLR function invokes Transact-SQL statements through impersonation calls, such as by calling the EXECUTE AS statement.

In this scenario, the execution fails, and you receive the following error message:


This fix is included in Cumulative Update 1 for SQL Server 2017.

Service pack information for SQL Server 2016

This issue is fixed in the following service pack for SQL Server:

       Service Pack 2 for SQL Server 2016


Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.


Learn about the terminology Microsoft uses to describe software updates.