CATEGORY ID
渡されたものに基づいて詳細をフェッチするストアド プロシージャを作成しています。渡されたものがCATEGORY ID
null でないCATEGORY ID
場合は、に基づいてCATEGORY ID
フェッチしています。この問題。CATEGORY ID
3
私の手順は次のようなものです:
CREATE procedure [dbo].[SearchAssetdetails]
(
@assetCategory as int = null,
@assetType as int = null,
@assetDescription as nvarchar(200) = null,
@purchaseDate as datetime = null,
@validUpto as datetime = null)
as
begin
select ad.CategoryID,ad.AssetTypeId,ad.AssetDetailId,ad.AssetDescription,ad.Cost,ad.IsOwn,ad.LastModifiedby,ad.LastModifiedDatetime,ad.Location,ad.NoofLicences,ad.PurchaseDate,ad.SerialNumber,ad.ValidUpto,ad.VendorId,ad.Version,ad.WarrantyExpirationDate
from AssetDetails ad where
(ad.AssetDescription like (case when @assetDescription is not null then '%'+@assetDescription+'%' else ad.AssetDescription end)
and ad.CategoryID=(case when @assetCategory is not null then @assetCategory else ad.CategoryID end)
and ad.AssetTypeId=(case when @AssetType is not null then @AssetType else ad.AssetTypeId end)
and ad.PurchaseDate=(case when @purchaseDate is not null then @purchaseDate else ad.PurchaseDate end)
and ad.ValidUpto=(case when @validUpto is not null then @validUpto else ad.ValidUpto end)
) end;