Re: Index and Begin With search

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Aaron Bertrand - MVP (aaron_at_TRASHaspfaq.com)
Date: 05/25/04


Date: Tue, 25 May 2004 14:49:50 -0400

Why would you want to assume anything? TEST IT.

-- 
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/
"A.M" <nospam1@online.nospam> wrote in message
news:uwwr2ioQEHA.3528@TK2MSFTNGP09.phx.gbl...
> Thank you for reply,
>
> Can I assume that LIKE is always faster than LEFT in where clause ?
>
> Thanks,
> Alan
>
>
>
> "Aaron Bertrand - MVP" <aaron@TRASHaspfaq.com> wrote in message
> news:us$J1GoQEHA.252@TK2MSFTNGP10.phx.gbl...
> > LIKE 'ala%' will at least consider the index, whereas computations like
> LEFT
> > or SUBSTRING will not.
> >
> > -- 
> > Aaron Bertrand
> > SQL Server MVP
> > http://www.aspfaq.com/
> >
> >
> >
> >
> > "A.M" <nospam1@online.nospam> wrote in message
> > news:ONLz9$nQEHA.1048@tk2msftngp13.phx.gbl...
> > > Hi,
> > >
> > > I have an index based on column "Name" called IDX_Name.
> > >
> > > I know that if I have a query to search for specific column, IDX_Name
> will
> > > be used.
> > >
> > > Now I want to search for Names that begin with sepcific letters. If I
> use
> > a
> > > query like:
> > >
> > > Select * from tblCustomer where Left(Name ,3) = 'ala'
> > >
> > > Then query processor won't utilise IDX_Name.
> > >
> > > How can I use index with "Begin With " kind of searchs?
> > >
> > > Thanks,
> > > Alan,
> > >
> > >
> > >
> >
> >
>
>


Relevant Pages

  • Re: searching through results
    ... > I just need to look through that Section A and if it has a bold, ... >> Why don't you do it from the query? ... >> Aaron Bertrand ... >> SQL Server MVP ...
    (microsoft.public.inetserver.asp.general)
  • Re: Query question. Can be very simple. Please take a look...
    ... > Aaron Bertrand ... > SQL Server MVP ... >> the query is not an issue and the number of query can be more than one ... >> TomTom ...
    (microsoft.public.sqlserver.programming)
  • Re: How to access sql table field description in asp.net.
    ... "Uri Dimant" wrote in message ... >> like you would any other query. ... >> Aaron Bertrand ... >> SQL Server MVP ...
    (microsoft.public.sqlserver.programming)
  • Re: select * vs select "single column"
    ... Aaron Bertrand ... SQL Server MVP ... "John GI" wrote in message ... > running a query through "Query Analyzer" and I get rows back within 14 ...
    (microsoft.public.sqlserver.server)
  • Re: Index and Begin With search
    ... > have a general rule for all situations. ... >> Aaron Bertrand ... >> SQL Server MVP ... >>> Alan ...
    (microsoft.public.sqlserver.programming)