>CREATE FUNCTION [dbo].[isIN] >( > @lcStr varchar(100) , > @lcList varchar(max) >) >RETURNS int >AS >BEGIN > > DECLARE @Test int = 0 > > if @lcStr = '' or @lcList='' > set @test=1 > else > if NOT (@lcStr is null or @lcList is null) > begin > declare @aa int > set @aa = charindex(','+@lcStr+',',','+@lcList+',') > if @aa>0 > set @Test = 1 > else > set @test = 0 > end > > RETURN @Test > >END >GO >>
>WHERE dbo.isIN([awb_manifestnumber], @awb_manifestnumber)>0 >This is very bad as you're not using index this way and making query slow by adding scalar UDF into WHERE. I advise you to never use such approach.