Re: LIKE vs Equals

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Jon (rosenberg_at_mainstreams.com)
Date: 02/14/05


Date: Mon, 14 Feb 2005 10:56:39 -0500

Thanks, all.

"Steve Kass" <skass@drew.edu> wrote in message
news:u$tq1BqEFHA.2876@TK2MSFTNGP12.phx.gbl...
> The query plans are different. LIKE does a little bit
> more work, though both will use an index if one is present,
> and the difference is slight. For readability alone, it is better
> to use = when you mean =.
>
> The only other difference I can think of is when the types
> of the column and literal are different. Since LIKE only
> operates on string data, a query like
>
> ... where integerColumn LIKE 123
> ... where integerColumn LIKE '123'
> ... where vCharColumn LIKE 123
>
> will implicitly convert both the column and literal as needed
> to string types, and this could result in differences from the =
> query.
>
> Steve Kass
> Drew University
>
> Jon wrote:
>
>>In my office there is a guy who programs like the following:
>>
>>SELECT 1 FROM Table where VCharField LIKE 'bob' as an equiavlent to
>>SELECT 1 FROM Table where VCharField = 'bob'
>>
>>Is there a performance hit with that? Or, does SQL server translate the
>>LIKE (with no wildcard) to an equals?
>>
>>Thanks for any input.
>>
>>Jon
>>
>>



Relevant Pages

  • Question about xp_sendmail and .CSV attachments.
    ... I'm using xp_sendmail to send the output of a query as a .CSV attachment. ... reason, all my string data is fixed length. ...
    (microsoft.public.sqlserver.server)
  • Re: convert memo to text
    ... I know that in a query I can use the ... in the query output. ... place of "Val" to convert a memo field to a text field? ... A memo field contains string data; ...
    (microsoft.public.access.queries)
  • Re: LIKE vs Equals
    ... The query plans are different. ... operates on string data, a query like ... where integerColumn LIKE '123' ... to string types, and this could result in differences from the = ...
    (microsoft.public.sqlserver.programming)
  • Re: convert memo to text
    ... A memo field contains string data; ... What function would i use in the query ... Prev by Date: ...
    (microsoft.public.access.queries)
  • Re: Execution plan
    ... faster if I use OUTER JOIN - optimizer use better query plans in that ... optimizer don't use this index? ... What happens if you drop the index on TransportStatus? ...
    (microsoft.public.sqlserver.programming)