Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 SQL Server Administration (2005)
 Search with \ character is taking longtime.

Author  Topic 

venkath
Posting Yak Master

202 Posts

Posted - 2009-01-09 : 09:40:45
Hi All

I have a query like following

SELECT ename
FROM emp
WHERE ename LIKE '%A\_B%' ESCAPE '\'
When I search the query with escape character, it takes forever to return 0 records.

When I remove \ character and execute the query, It executes quickly.

I checked the execution plan of the query. It is not showing any table scans or clusterd index scans.

ENAME column has index on it.

Can you please clarify me why the searches with escape characters are taking long time.


Thank you all

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2009-01-09 : 09:43:50
See Full text indexing.
Go to Top of Page

darkdusky
Aged Yak Warrior

591 Posts

Posted - 2009-01-09 : 11:15:23
You need an extra backslash to escape the other backslash:

SELECT ename
FROM emp
WHERE ename LIKE '%A\\_B%' ESCAPE '\'
Go to Top of Page

venkath
Posting Yak Master

202 Posts

Posted - 2009-01-09 : 12:02:15
Why do we need extra \ to ignore '_' as a wild card character.I believe single \ is enough.

apart from full index, is'nt there any option to improve the performance.

Thanks
Go to Top of Page
   

- Advertisement -