sql - User Defined Function to determine whether string contains a substring -


i have code returning 0 regardless if string contains substring or not. should return 1 if substring found.

create function dbo.checkletters (@message varchar) returns integer returns null on null input begin     declare @value integer;     if @message '%findme%'         set @value = 1     else         set @value = 0     return @value end; 

i tried using charindex in if statement no avail. missing simple here?

testing so:

select dbo.checkletters('dlhld'); 

use (@message varchar(max)) input parameter. or instead of max specify length, in function 1. issue.


Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -