Re: LIKE vs Equals
From: Jon (rosenberg_at_mainstreams.com)
Date: 02/14/05
- Next message: drisso_at_ortc.com: "Update an Entire Table Row using Update and Select"
- Previous message: Alejandro Mesa: "Re: Time query repost"
- In reply to: Steve Kass: "Re: LIKE vs Equals"
- Next in thread: JohnnyAppleseed: "Re: LIKE vs Equals"
- Messages sorted by: [ date ] [ thread ]
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
>>
>>
- Next message: drisso_at_ortc.com: "Update an Entire Table Row using Update and Select"
- Previous message: Alejandro Mesa: "Re: Time query repost"
- In reply to: Steve Kass: "Re: LIKE vs Equals"
- Next in thread: JohnnyAppleseed: "Re: LIKE vs Equals"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|