Tuesday, February 14, 2012

differences between "=" and "like" operators

Do you know where can I find technical specification of the differences
between the operator "=" and the operator "like"
I know that we can use like with the "%" to search part of a string, but
I want to know if exists others differences of functionality and performance
Thanks
AA
HI,
There is no difference between and Like. Both the operators will be used
based on the requirement. It is always good to use = in search criteria
(because Query optimizer will be able to use the index and get the best path)
, but there are instances we need to use LIKE operator to attain our
objective. See the below link detailing the performance benifit
http://www.sql-server-performance.com/transact_sql.asp
See the below links detailing both operators.
http://msdn.microsoft.com/library/de.../vaoprlike.asp
http://msdn.microsoft.com/library/de.../vaoprlike.asp
Thanks
Hari
SQL Server MVP
"Anibal Acosta" wrote:

> Do you know where can I find technical specification of the differences
> between the operator "=" and the operator "like"
> I know that we can use like with the "%" to search part of a string, but
> I want to know if exists others differences of functionality and performance
> Thanks
> AA
>
|||Thanks!!
AA
Hari Prasad wrote:[vbcol=seagreen]
> HI,
> There is no difference between and Like. Both the operators will be used
> based on the requirement. It is always good to use = in search criteria
> (because Query optimizer will be able to use the index and get the best path)
> , but there are instances we need to use LIKE operator to attain our
> objective. See the below link detailing the performance benifit
> http://www.sql-server-performance.com/transact_sql.asp
> See the below links detailing both operators.
> http://msdn.microsoft.com/library/de.../vaoprlike.asp
> http://msdn.microsoft.com/library/de.../vaoprlike.asp
> Thanks
> Hari
> SQL Server MVP
>
> "Anibal Acosta" wrote:
>
|||Hmm, first you say there is no difference, then you post a link that
explains that some characters have a special meaning (i.e. they behave
differently). Also, the link refers to Like in Visual Basic. The
patterns described there are not supported in T-SQL.
Take a look at "LIKE comparisons" in BOL, and you will see that any time
you use any of the characters %, _, [], and [^] have special meaning and
will potentially return different rows when compared to =.
Gert-Jan
Hari Prasad wrote:[vbcol=seagreen]
> HI,
> There is no difference between and Like. Both the operators will be used
> based on the requirement. It is always good to use = in search criteria
> (because Query optimizer will be able to use the index and get the best path)
> , but there are instances we need to use LIKE operator to attain our
> objective. See the below link detailing the performance benifit
> http://www.sql-server-performance.com/transact_sql.asp
> See the below links detailing both operators.
> http://msdn.microsoft.com/library/de.../vaoprlike.asp
> http://msdn.microsoft.com/library/de.../vaoprlike.asp
> Thanks
> Hari
> SQL Server MVP
> "Anibal Acosta" wrote:

No comments:

Post a Comment