CHARINDEX always 0 when looking for substring
I have the following in a field ABCD, EFG, HIJ and can confirm this by selecting it. I need to be able to search this string for ABCD so I used the following:
case
when CHARINDEX(g.letters ,'ABCD') 开发者_开发百科<> 0
then (- 2)
else (- 1)
end
However its always returning -1
Try
CHARINDEX('ABCD', g.letters)
The first parameter is the expression to find and the second parameter is the expression to be searched.
精彩评论