製品のリストを検索する場合、@SearchTypeパラメーターはオプションです。@SearchTypeが空の場合、またはすべての製品を返し、句NULLを使用しない必要があります。WHEREそれ以外の場合、合格しEquipmentた場合は代わりにそれを使用します。
ALTER PROCEDURE [dbo].[psProducts]
(@SearchType varchar(50))
AS
BEGIN
SET NOCOUNT ON;
SELECT
P.[ProductId],
P.[ProductName],
P.[ProductPrice],
P.[Type]
FROM [Product] P
-- if @Searchtype is not null then use the where clause
WHERE p.[Type] = @SearchType
END
