我有一个存储过程使用下面的代码。案例声明在哪里条款
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