I have a stored procedure with the following code.
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
what I want is
if(@IsCategory= 1) then
TBM_Product.SubCategoryID is null
else
void this and condition
how to achieve this.I am getting "incorrect syntax near =" error while compiling the above stored procedure.