>WHERE (@ProductId IS NULL OR ProductId = @ProductId) AND > (@Product_Series IS NULL OR Product_Series = @Product_Series) AND > (@Product_Number IS NULL OR Product_Number = @Product_Number) AND > (@Product_Name IS NULL OR Product_Name = @Product_Name) AND > (@Product_Description IS NULL OR Product_Description = @Product_Description) >>With OR between your conditions of course you would get the whole table.
EXEC ap_GetProducts @Product_Number = 'A3671A'>>
>> 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) >>>>
>>>>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 >>>>>>>>
>>>>EXEC ap_GetProducts -- No params passed >>>>>>>>
>>>>SELECT * FROM HPProductsData >>>>>>>>
>>>>SELECT * FROM HPProductsData WHERE Product_Name != NULL >>>>>>>>