开发者

CHARINDEX always 0 when looking for substring

开发者 https://www.devze.com 2023-01-18 00:30 出处:网络
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:

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消