Microsoft KB Archive/275536

From BetaArchive Wiki
Knowledge Base


Article ID: 275536

Article Last Modified on 3/14/2006



APPLIES TO

  • Microsoft SQL Server 7.0 Standard Edition



This article was previously published under Q275536

BUG #: 58361 (SQLBUG_70)

SYMPTOMS

A query that has a LIKE clause, which contains a hyphen character "-", may run slower than expected against a non-SQL Server linked server for a remote table with a large number of rows.

CAUSE

You can use the hyphen character "-" as a pattern match character for ranges in SQL Server (such as [a-z]), but it is not an ANSI SQL standard pattern matching character. SQL Server incorrectly flags the hyphen character "-" as a non-ANSI pattern matching character instead of a literal hyphen ("-") and therefore prevents the criteria from being sent to the remote provider.

WORKAROUND

If the linked server provider supports it, use the OPENQUERY rowset function to force the entire query to be passed to the remote server.

STATUS

Microsoft has confirmed this to be a problem in SQL Server 7.0. This problem has been corrected in U.S. Service Pack 3 for Microsoft SQL Server 7.0. For more information, click the following article number to view the article in the Microsoft Knowledge Base:

274799 INF: How to Obtain Service Pack 3 for Microsoft SQL Server 7.0 and Microsoft Data Engine (MSDE) 1.0


For more information, contact your primary support provider.

MORE INFORMATION

In this situation, the LIKE clause criteria is applied at the local SQL Server server after retrieving all rows from the remote table. So, a query like this:

select * from myremoteserver.mycatalog.myschema.mytable where col1 LIKE 'MS-'
                

is processed as follows:

  1. All rows from mytable are retrieved from the linked server to the local SQL Server server.
  2. The local SQL Server server then applies the LIKE clause criteria to produce the final result. Optimally, the remote source should handle applying the criteria so that less rows are returned to the local SQL Server server.


Keywords: kbbug kbfix kbqfe KB275536