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

Article translations Article translations
Article ID: 959019 - View products that this article applies to.
Expand all | Collapse all

On This Page

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

Properties

Article ID: 959019 - Last Review: December 16, 2008 - Revision: 1.0
APPLIES TO
  • Microsoft SQL Server 2005 Standard Edition
  • Microsoft SQL Server 2005 Developer Edition
  • Microsoft SQL Server 2005 Enterprise Edition
  • Microsoft SQL Server 2005 Standard X64 Edition
  • Microsoft SQL Server 2005 Standard Edition for Itanium-based Systems
  • Microsoft SQL Server 2005 Enterprise X64 Edition
  • Microsoft SQL Server 2005 Enterprise Edition for Itanium-based Systems
  • Microsoft SQL Server 2005 Workgroup Edition
Keywords: 
kbsql2005engine kbtshoot kbexpertiseadvanced kbfix kbbug KB959019

Give Feedback

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com