Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Query Problem
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Stored procedures, Triggers, UDFs
Titre:
Divers
Thread ID:
01381088
Message ID:
01381094
Vues:
25
Ok, that reversed the problem.

Now if I call it with no params, I get back the whole table, as I should.... But if I call it with:
EXEC ap_GetProducts @Product_Number = 'A3671A'
I also still get back all rows:
	SELECT *
		FROM HPProductsData
		WHERE (@ProductId IS NULL OR ProductId = @ProductId) OR
			  (@Product_Series IS NULL OR Product_Series = @Product_Series) OR
			  (@Product_Number IS NULL OR Product_Number = @Product_Number) OR
			  (@Product_Name IS NULL OR Product_Name = @Product_Name) OR
			  (@Product_Description IS NULL OR Product_Description = @Product_Description)
>Kevin,
>
>Yes, that's the limitation of this particular approach. Use slightly different verison
>
>@myParam IS NULL OR myField = @MyParam
>
>BTW, this exact question was discussed a while ago on ASP.NET/Forums.
>
>I'll search later on, if you're interested in that discussion.
>
>>I'm working on this sproc:
>>
>>
>>SET ANSI_NULLS OFF
>>GO
>>SET QUOTED_IDENTIFIER ON
>>GO
>>
>>CREATE PROCEDURE ap_GetProducts
>>	(@ProductId                     INT = NULL,
>>	 @Product_Series            VARCHAR(100)= NULL,
>>	 @Product_Number          VARCHAR(20)= NULL,
>>	 @Product_Name             VARCHAR(100)= NULL,
>>	 @Product_Description     VARCHAR(MAX)= NULL)
>>
>>AS
>>BEGIN
>>
>>	SELECT *
>>		FROM HPProductsData
>>		WHERE ProductId				= ISNULL(@ProductId, ProductId) AND
>>			  Product_Series		= ISNULL(@Product_Series, Product_Series )AND
>>			  Product_Number		= ISNULL(@Product_Number, Product_Number) AND
>>			  Product_Name			= ISNULL(@Product_Name, Product_Name) AND
>>			  Product_Description	= ISNULL(@Product_Description, Product_Description)
>>	
>>END
>>
>>
>>
>>When I run it like this:
>>
>>
>>EXEC ap_GetProducts    -- No params passed
>>
>>
>>I get back 1310 records
>>
>>If I run this
>>
>>
>>SELECT * FROM HPProductsData
>>
>>
>>I get back 44786 records
>>
>>if I do this
>>
>>
>>SELECT * FROM HPProductsData WHERE Product_Name != NULL
>>
>>
>>I get back 1310 records
>>
>>
>>So, my query is only returning records with a non-null Product_Name. I have SET ANSI_NULLS OFF.
Everything makes sense in someone's mind
public class SystemCrasher :ICrashable
In addition, an integer field is not for irrational people
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform