Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Using IN() and parameter
Message
 
 
À
07/02/2013 19:03:24
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Divers
Thread ID:
01565428
Message ID:
01565449
Vues:
49
>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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform