ALTER PROCEDURE [dbo].[sp_Products_GetRecordCountWhereDynamic]
    @productID int = NULL,
    @productName nvarchar (40) = NULL,
    @supplierID int = NULL,
    @categoryID int = NULL,
    @quantityPerUnit nvarchar (20) = NULL,
    @unitPrice money = NULL,
    @unitsInStock smallint = NULL,
    @unitsOnOrder smallint = NULL,
    @reorderLevel smallint = NULL,
    @discontinued bit = NULL
) 
AS 
BEGIN 
   SET NOCOUNT ON;
 
   SELECT COUNT (*) AS RecordCount FROM [dbo].[Products]
   WHERE
   ([ProductID]  = @productID OR @productID IS NULL) AND
   ([ProductName]  LIKE '%' + @productName + '%' OR @productName IS NULL) AND
   ([SupplierID]  = @supplierID OR @supplierID IS NULL) AND
   ([CategoryID]  = @categoryID OR @categoryID IS NULL) AND
   ([QuantityPerUnit]  LIKE '%' + @quantityPerUnit + '%' OR @quantityPerUnit IS NULL) AND
   ([UnitPrice]  = @unitPrice OR @unitPrice IS NULL) AND
   ([UnitsInStock]  = @unitsInStock OR @unitsInStock IS NULL) AND
   ([UnitsOnOrder]  = @unitsOnOrder OR @unitsOnOrder IS NULL) AND
   ([ReorderLevel]  = @reorderLevel OR @reorderLevel IS NULL) AND
   ([Discontinued]  = @discontinued OR @discontinued IS NULL)
 
END