製品のリストを検索する場合、@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