-- Use the Specify Values for Template Parameters
-- command (Ctrl-Shift-M) to fill in the parameter
-- values below.
--
-- This block of comments will not be included in
-- the definition of the procedure.
-- ================================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
alter PROCEDURE [dbo].[PageTree]
@WebSitePageId uniqueidentifier
AS
with PageTree(Id, ParentPage_Id) AS
(
SELECT Page1.Id, Page1.ParentPage_Id
FROM WebSitePage AS Page1
WHERE Page1.Id=@WebSitePageId
UNION ALL
SELECT Page2.Id, Page2.ParentPage_Id
FROM PageTree, WebSitePage Page2
WHERE PageTree.ParentPage_Id = Page2.Id
)
Select Id, AppendWebSitePageId, MenuTitle, PagePath From WebsitePage Where Id in (
SELECT DISTINCT Id FROM PageTree )
GO
No comments:
Post a Comment