我有一個存儲過程使用下面的代碼。案例聲明在哪裏條款
alter PROCEDURE [dbo].[usp_Product_GetProductByCategoryID]
@CategoryID uniqueidentifier,
@IsCategory bit=0
AS
BEGIN
SELECT ProductId, ProductCode, ProductName, MRP, MaxDiscount,
ShortDescription, ThumbNailImagePath,ThumbNailImagePath1,
FullImagePath, IsActive, NoOfBuyer,
LongDescription, BrandID, SubCategoryID, CreatedDate,
LargeThumbnailImagePath, VideoPath
FROM TBM_Product
WHERE (case @IsCategory
when 0 then TBM_Product.SubCategoryID
when 1 then TBM_Product.CategoryID
end)
= @CategoryID
*AND (case
when @IsCategory= 0 then TBM_Product.SubCategoryID = TBM_Product.SubCategoryID
when @IsCategory= 1 then TBM_Product.SubCategoryID is null
end)*
END
我要的是
如果(@ IsCategory = 1),則
TBM_Product.SubCategoryID is null
其他
void this and condition
如何實現this.I我越來越「近不正確的語法=「編譯上述存儲過程時出現錯誤。
從你的代碼看起來好像你試圖在WHERE子句中設置@CategoryID變量? – Kane 2009-09-08 07:53:27