Brug case statement:
SELECT ProductID, ProductName,ProductDesc
FROM product
WHERE ProductID = CASE WHEN @productID IS NULL THEN ProductID ELSE @productID END
Eller IIF()-funktionen, hvis du bruger SQL Server 2012:
SELECT ProductID, ProductName,ProductDesc
FROM product
WHERE ProductID =IIF(@productID IS NULL, ProductID, @productID )