I am creating sql queries and I have read in one book that when using NOT operator or LIKE operators Indexes do not work. How much true this statement is. How can we avoid this if the statement is true. How a query should be made to do the same work avoiding these operators.
What all other areas are there in sql server where Indexes are deferred.
Like statements that wildcard the leftside can not use an index if one is defined for the column:
But either of these can use an index:
Frankly, use LIKE for very simple text searching – if you’re really needing a text search that performs well, look at Full Text Searching (FTS). Full Text Searching has it’s own indexes.
The decision really comes down to the optimizer for which index to use, but something that ensures that an index will not be used it to wrap column values in function calls. This for example will not use indexes:
Anywhere you are manipulating table data–especially changing the data type–will render an index useless because an index is of the unaltered values and there’s no way to relate to altered data.