This article was previously published under Q275536
This article has been archived. It is offered "as is" and will no longer be updated.
BUG #: 58361 (SQLBUG_70)
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.
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.
If the linked server provider supports it, use the OPENQUERY rowset function to force the entire query to be passed to the remote server.
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.
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:
All rows from mytable are retrieved from the linked server to the local SQL Server server.
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.