Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

FIX: Data type conversion error due to late evaluation of a filter predicate in a query involving a column store index in SQL Server 2016


View products that this article applies to.

Symptoms

Consider the following scenario:

  • You use a database with the compatibility level set to 130 in Microsoft SQL Server 2016.
  • You execute a query that accesses a column store index and a row store index or a heap, and includes a filter predicate (WHERE clause).
In this scenario, SQL Server will not be able to push the filter predicate closer to the data source operator (table or index scan or seek). This may cause suboptimal query performance.

In addition, if the query uses an expression (such as type conversion) where its correctness depends on filtered data (for example, a char table column is converted to int, but only a subset of values contain a valid int representation, and this subset is identified by the filter predicate), then the query may fail with a data conversion error that resembles one of the following:
Msg 245, Level 16, State 1, Line 20
Conversion failed when converting the varchar value '0.5' to data type int.

Msg 8114, Level 16, State 5, Line 34
Error converting data type varchar to bigint.

↑ Back to the top


Resolution

This issue is fixed in the following cumulative update for SQL Server:

       Cumulative Update 2 for SQL Server 2016 SP1

Note You must enable query optimizer hotfixes in order for this fix to take effect.

You can enable the query optimizer hotfixes by using one of the following options: trace flag 4199, Database Scoped Configuration setting QUERY_OPTIMIZER_HOTFIXES=ON (available in SQL Server 2016 and later), or USE_HINT query option 'ENABLE_QUERY_OPTIMIZER_HOTFIXES' (available in SQL Server 2016 SP1 and later).

About cumulative updates for SQL Server

Each new cumulative update for SQL Server contains all the hotfixes and all the security fixes that were included with the previous cumulative update. Check out the latest cumulative updates for SQL Server:

Latest cumulative update for SQL Server 2016

 

↑ Back to the top


Status

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

↑ Back to the top


References

Learn about the terminology that Microsoft uses to describe software updates.

↑ Back to the top


Keywords: kbqfe, kbfix, kbsurveynew, kbexpertiseadvanced, kb

↑ Back to the top

Article Info
Article ID : 4013883
Revision : 11
Created on : 3/21/2017
Published on : 3/21/2017
Exists online : False
Views : 418