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 2000 Forums
 SQL Server Development (2000)
 CHARINDEX vs LIKE

Author  Topic 

dsetzer
Starting Member

31 Posts

Posted - 2001-01-29 : 12:12:26
I am doing a query where I want only results returned that contain a specific string in a varchar field.

Which would be faster?


select id
from table
where textfield like '%test%'

or --

select id
from table
where charindex('test', textfield) > 0


What can I do to make this the fastest executing query? Should I build an index on the textfield?

Thanks for any help from a programmer doing DBA things!
   

- Advertisement -