Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

Now for my thesis project i need to make a lot of queries like the below

select * from tblMyTable where ItemName like '%item%'

Now my question : is that possible to create indexes for such queries ? If so what is the way of doing it ? Thank you.

share|improve this question
add comment

migrated from stackoverflow.com Feb 21 '12 at 13:56

This question came from our site for professional and enthusiast programmers.

2 Answers

up vote 4 down vote accepted

For LIKE queries this is not available.

But for making such queries SQL Server provides functionality called Full-text search. More info in MSDN.

share|improve this answer
    
So when i set full-text search will i be able to still use the query above ? Or i need different format ? –  MonsterMMORPG Feb 21 '12 at 14:02
    
You will need a different format and you will need to use Filltext-specific functions to achieve needed result. Also result will be language-specific to your database. Please refer to MSDN: Querying SQL Server Using Full-Text Search for further information. I do understand that might be not what you're looking for but that's the best SQL Server can offer for handling such needs. –  Sergey Kudriavtsev Feb 21 '12 at 15:21
add comment

index will work if you have something like

where ItemName like 'item%'

also contains works much faster than like, see this: http://www.docstoc.com/docs/2280727/Microsoft-SQL-Server-70-Full-Text-Search-What-is-full-text-search

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.