I have a simple select and two parameters.
@first
@second
SELECT ProductID, ProductName, ProductType, ProductLevel
FROM ProductTable
When I execute the procedure if both parameters have no values then I need this part to be executed:
WHERE ProductType = 1 AND ProductLevel = 1
IF I have value of first parameter then :
WHERE ProductType = 2 AND ProductName LIKE @first + '%'
IF I have value of second parameter then :
WHERE ProductType =3 AND ProductName LIKE @second + '%'
Can someone help me to implement this logic and create valid stored procedure ?