FIX: You receive an incorrect result when you run a query that uses the LIKE operator in SQL Server 2005

Symptoms

Consider the following scenario. In Microsoft SQL Server 2005, you run a query that uses the LIKE operator. The execution plan of the query uses the GetRangeThroughConvert function. When you run the query, you may receive an incorrect result. For example, the execution plan for this query may resemble the following.
|--Nested Loops(Inner Join, OUTER REFERENCES:([Expr1010], [Expr1011], 
|[Expr1012]))
|--Merge Interval
| |--Concatenation
| |--Compute Scalar(DEFINE:(([Expr1005],[Expr1006],[Expr1004])=GetRangeThroughConvert(N'P08.89',NULL,(22))))
| | |--Constant Scan
| |--Compute Scalar(DEFINE:(([Expr1008],[Expr1009],[Expr1007])=GetRangeThroughConvert(NULL,N'P08.8?',(10))))
| |--Constant Scan
|--Index Seek(OBJECT:([TestLikeBug].[dbo].[Projects].[IX_Projects]),
SEEK:( [TestLikeBug].[dbo].[Projects].[ProjectNumber] > [Expr1010] AND
[TestLikeBug].[dbo].[Projects].[ProjectNumber] < [Expr1011]),
WHERE:(CONVERT_IMPLICIT(nvarchar(12),[TestLikeBug].[dbo].[Projects].[ProjectNumber],0) like N'P08.89%')
ORDERED FORWARD)

Cause

This issue occurs because SQL Server generates an incorrect range condition for the LIKE operator.

Resolution

Service pack information

To resolve this problem, obtain the latest service pack for SQL Server 2005. For more information, click the following article number to view the article in the Microsoft Knowledge Base:
913089 How to obtain the latest service pack for SQL Server 2005

Status

Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section. This problem was first corrected in SQL Server 2005 Service Pack 3.

More Information

For more information about software update terminology, click the following article number to view the article in the Microsoft Knowledge Base:
824684 Description of the standard terminology that is used to describe Microsoft software updates
Свойства

Номер статьи: 959019 — последний просмотр: 15 дек. 2008 г. — редакция: 1

Отзывы и предложения