Sql server

Store Procedure to get a Multiple Category

WITH CATEGORYVIEW (cat_Id, cat_ParentId,cat_orgname, cat_name,Main_catId,MainCatName ,cat_image,cat_displayorder,cat_IsShow) AS
(
SELECT cat_Id, cat_ParentId,cat_name,cast(cat_name as varchar(255)),cast(cat_Id as varchar(255)),cast(cat_name as varchar(255)),cat_image,cat_displayorder,cat_IsShow
FROM [CATEGORY_MST]
WHERE isnull(cat_ParentId,0) = 0

UNION ALL

SELECT C.cat_Id, C.cat_ParentId,c.cat_name ‘cat_orgname’, cast(CATEGORYVIEW.cat_name+’/’+C.cat_name as varchar(255)),cast(CATEGORYVIEW.cat_Id as varchar(255)),cast(CATEGORYVIEW.MainCatName as varchar(255)),C.cat_image,C.cat_displayorder,C.cat_IsShow
FROM [CATEGORY_MST] C
JOIN CATEGORYVIEW ON CATEGORYVIEW.cat_Id = C.cat_ParentId
)
SELECT * FROM CATEGORYVIEW

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.