CREATE PROCEDURE [dbo].[Products_SelectAllByCategoryID] ( @categoryID int ) AS BEGIN SET NOCOUNT ON; SELECT [ProductID], [ProductName], [SupplierID], [CategoryID], [QuantityPerUnit], [UnitPrice], [UnitsInStock], [UnitsOnOrder], [ReorderLevel], [Discontinued] FROM [dbo].[Products] WHERE ([CategoryID] = @categoryID AND 1 = CASE WHEN @categoryID IS NULL THEN 0 ELSE 1 END) OR ([CategoryID] IS NULL AND 1 = CASE WHEN @categoryID IS NULL THEN 1 ELSE 0 END) END