Need help in below.
I am using sql seerver 2008 and have a query in which i am using like operator.
when i am using a part of string then its working fine however when i am using complete string in like operator database is not populating any results.
for example.
i have table EMp which containd description column.
if descreption column contains
Description
-------------------------------------------------
'John joined on Wednesday/CELL PHONE [1234567890]'
when i am writing query
select * from EMp where
description like '%CELL%'
its working fine
however when i am writing my query as
select * from EMp where
description like '%John joined on Wednesday/CELL PHONE [1234567890]%'
its not returning any value.
does it mean that like operator works only part of string and not on full string.
I have also tried LTRIM and RTRIM just to make sure that space is not a problem however its not working.
Thanks
Keep in mind that
LIKEsupports a limited set of pattern matches in addition to the wildcard%. One of those patterns includes brackets for matching a range.See: http://msdn.microsoft.com/en-us/library/ms179859.aspx
The brackets in your query will cause it to search for “Any single character within the specified range ([a-f]) or set ([abcdef]).”
Thus, your query is asking for SQL Server to find a character within the set [1234567890].
If you read through the MSDN documentation, it provides guidelines for using wildcard characters as literals. Here’s a little example:
Note that full text indexing may be more useful if you want to search larger strings with more complex patterns. It is supported in all editions of SQL Server 2008 (even Express).