Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Using IN() and parameter
Message
 
 
To
07/02/2013 19:03:24
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Miscellaneous
Thread ID:
01565428
Message ID:
01565449
Views:
48
>I created a user function to handle this.
>
>
>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
>
>
>then, in the conditional clause I would
>
>
>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.
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform