'SQL Server query never completing when a column in included

We've just come across a rather weird issue with SQL Server 2017. We have a query which should be returning around 60 rows. However it never completes. Experimenting in Management Studio, we get the same behaviour as the application which normally executes this query.

We've tracked the issue down to a single column called Descr, an nvarchar(100) column. It's not being filtered on. I.e it doesn't appear in a WHERE clause. It's not a calculated column. It's just a plain old nvarchar containing descriptions.

If we comment out the column from the select, the query finishes instantly. So obviously something weird is going on with the column. But what?

If we include left(Descr, 1) as a column, then the query completes instantly.

If we include left(Descr, 100), it never completes.

Obviously we can't use the query plan as the query is not completing. At a loss here.

Any ideas/suggestions of stuff we can investigate/try out?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source