У меня есть хранимая процедура со следующим кодом.case statement in where where
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 я получаю «неправильный синтаксис около = "при компиляции вышеуказанной хранимой процедуры.
Из вашего кода кажется, что вы пытаетесь установить переменную @CategoryID в предложении WHERE ??? – Kane