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
Post a Comment