Query Store returns unusual characters when a JOIN operator is used in SQL Server 2016

Applies to: SQL Server 2016 DeveloperSQL Server 2016 EnterpriseSQL Server 2016 Enterprise Core More

Symptoms


Assume that you enable the Query Store feature for a database in an instance of SQL Server 2016. When you query the query plan by using join operations, the query_plan column in the query result contains unusual characters.

For example, you join sys.query_store_plan to another view, as in the following query:

SELECT qt.query_sql_text, q.query_id, qt.query_text_id, p.plan_id, p.query_plan
FROM sys.query_store_query_text AS qt
         INNER JOIN sys.query_store_query AS q ON qt.query_text_id = q.query_text_id
         INNER JOIN sys.query_store_plan AS p ON q.query_id = p.query_id

In this situation, the query_plan column in the query result contains characters such as the following:

传/傳

Resolution


The fix for this issue is included in the following cumulative update for SQL Server:

Workaround


To work around this issue, do not join sys.query_store_plan to another view when you try to retrieve query_plan. Instead, to retrieve query_plan for a given plan_id, run a separate query for that plan_id that resembles the following:

select plan_id, query_plan
from sys.query_store_plan
where plan_id = plan_id

Status


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

References


Learn about the terminology Microsoft uses to describe software updates.