Like does not work with * | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

Like does not work with *

Hi Group,
I have a field (definition varchar length 4 chars).
I have the following sample data in this field D6, d3, d5.
Note the UPPERCASE D for the D6 value – this could be why I’m experiencing the following. If I do the following:
SELECT *
FROM tblData2
WHERE (SG LIKE ‘d*’), no rows are returned even with ‘D*’. However if I do this for each occurence in the table, results are returned i.e like this SELECT *
FROM tblData2
WHERE (SG LIKE ‘d6’) SELECT *
FROM tblData2
WHERE (SG LIKE ‘d3’) The case does not seem to matter when I use the above select statements – I’ve used both UPPER and lower case. They both produce the same results. Kind Regards

If you are unsure about whether the database uses a case-sensitive search, you can use the UPPER or LOWER functions in the search condition to convert the case of the search data. Satya SKJ
Moderator
http://www.SQL-Server-Performance.Com/forum
This posting is provided “AS IS” with no rights for the sake of knowledge sharing.
The wildcard token for a LIKE statement is ‘%’ not ‘*’.
So WHERE (SG LIKE ‘d%’) will presumably return what you want
Thanks Chappy!! That did the trick!! I’m so used to using the * – my background is Access!! Regards
quote:Originally posted by Chappy The wildcard token for a LIKE statement is ‘%’ not ‘*’.
So WHERE (SG LIKE ‘d%’) will presumably return what you want

]]>