When searching for a list of products, the @SearchType parameter is optional. If @SearchType is empty or NULL then it should return al
If you don't want to pass the parameter when you don't want to search, then you should make the parameter optional instead of assuming that '' and NULL are the same thing.
ALTER PROCEDURE [dbo].[psProducts]
(
@SearchType varchar(50) = NULL
)
AS
BEGIN
SET NOCOUNT ON;
SELECT P.[ProductId]
,P.[ProductName]
,P.[ProductPrice]
,P.[Type]
FROM dbo.[Product] AS P
WHERE p.[Type] = COALESCE(NULLIF(@SearchType, ''), p.[Type]);
END
GO
Now if you pass NULL, an empty string (''), or leave out the parameter, the where clause will essentially be ignored.