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 -

how to prompt save As Box in Excel Interlop c# MVC 4 -

xslt 1.0 - How to access or retrieve mets content of an item from another item? -