Is there a way to write the following script so that it returns all products if the ProductID variable is null ? And return a specific product when the product it is not nul
Why not just:
DECLARE @productID INT = NULL SELECT ProductID, ProductName,ProductDesc FROM product WHERE ProductID = @productID OR @productID IS NULL;
Here a demo in SQLFiddle with NULL and a value for @productID