How can I tell if a VARCHAR variable contains a substring?

后端 未结 4 669
我在风中等你
我在风中等你 2021-01-30 20:07

I thought it was CONTAINS, but that\'s not working for me.

I\'m looking to do this:

IF CONTAINS(@stringVar, \'thisstring\')
   ...
<         


        
4条回答
  •  鱼传尺愫
    2021-01-30 20:16

        IF CHARINDEX('TextToSearch',@TextWhereISearch, 0) > 0 => TEXT EXISTS
    
        IF PATINDEX('TextToSearch', @TextWhereISearch) > 0 => TEXT EXISTS
    
        Additionally we can also use LIKE but I usually don't use LIKE.
    

提交回复
热议问题