Click here to Skip to main content
15,900,816 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: Yay! The real thing! Pin
OriginalGriff12-Feb-17 2:19
mveOriginalGriff12-Feb-17 2:19 
GeneralRe: Yay! The real thing! Pin
Kornfeld Eliyahu Peter12-Feb-17 3:10
professionalKornfeld Eliyahu Peter12-Feb-17 3:10 
GeneralRe: Yay! The real thing! Pin
Jon McKee12-Feb-17 11:16
professionalJon McKee12-Feb-17 11:16 
GeneralRe: Yay! The real thing! Pin
Brady Kelly12-Feb-17 22:50
Brady Kelly12-Feb-17 22:50 
GeneralRe: Yay! The real thing! Pin
OriginalGriff12-Feb-17 23:10
mveOriginalGriff12-Feb-17 23:10 
GeneralRe: Yay! The real thing! Pin
Brady Kelly13-Feb-17 0:48
Brady Kelly13-Feb-17 0:48 
GeneralRe: Yay! The real thing! Pin
Richard Deeming12-Feb-17 2:27
mveRichard Deeming12-Feb-17 2:27 
GeneralRe: Yay! The real thing! Pin
OriginalGriff12-Feb-17 2:46
mveOriginalGriff12-Feb-17 2:46 
It's all ancestors and descendants I needed - and I managed it quite well: Never really got my head round recursive CTE's though! Laugh | :laugh:
ALTER PROCEDURE [dbo].[spGetChildPages]
    @PageID UNIQUEIDENTIFIER
AS
BEGIN
	SET NOCOUNT ON;
    DECLARE @Empty UNIQUEIDENTIFIER;
    SET @Empty = dbo.fGetEmptyGuid();
    WITH Children AS(
        SELECT * FROM Pages WHERE ID = @PageID AND ID != @Empty
        UNION ALL
        SELECT p.* FROM Pages p
           INNER JOIN Children c ON p.ParentID = c.ID
    )
    SELECT * FROM Children WHERE ID != @PageID;
END

ALTER PROCEDURE [dbo].[spGetParentPages]
    @PageID UNIQUEIDENTIFIER
AS
BEGIN
	SET NOCOUNT ON;
    DECLARE @Empty UNIQUEIDENTIFIER;
    SET @Empty = dbo.fGetEmptyGuid();
    WITH Parents AS (
       SELECT *, 1 AS Level FROM Pages WHERE ID = @PageID AND ParentID != @Empty
       UNION ALL
       SELECT p.*, Level+1 AS Level FROM Pages p
	       INNER JOIN Parents pp ON p.Id = pp.ParentId AND pp.ID != @Empty
    )
    SELECT ID, PageName, ParentID, SetID
    FROM Parents 
    WHERE ID != @Empty AND ID != @PageID
    ORDER BY level DESC
END
I needed them for a hierarchical set of pages with a delete and restore feature.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...

GeneralRe: Yay! The real thing! Pin
Jörgen Andersson12-Feb-17 10:28
professionalJörgen Andersson12-Feb-17 10:28 
GeneralRe: Yay! The real thing! Pin
OriginalGriff12-Feb-17 10:51
mveOriginalGriff12-Feb-17 10:51 
GeneralRe: Yay! The real thing! Pin
Mycroft Holmes12-Feb-17 21:52
professionalMycroft Holmes12-Feb-17 21:52 
GeneralRe: Yay! The real thing! Pin
Jörgen Andersson13-Feb-17 3:57
professionalJörgen Andersson13-Feb-17 3:57 
GeneralRe: Yay! The real thing! Pin
Mike Hankey12-Feb-17 3:15
mveMike Hankey12-Feb-17 3:15 
GeneralRe: Yay! The real thing! Pin
OriginalGriff12-Feb-17 3:30
mveOriginalGriff12-Feb-17 3:30 
GeneralRe: Yay! The real thing! Pin
Mike Hankey12-Feb-17 3:39
mveMike Hankey12-Feb-17 3:39 
GeneralRe: Yay! The real thing! Pin
OriginalGriff12-Feb-17 3:50
mveOriginalGriff12-Feb-17 3:50 
GeneralI only have to switch the roles to feel home... Pin
Kornfeld Eliyahu Peter11-Feb-17 21:02
professionalKornfeld Eliyahu Peter11-Feb-17 21:02 
GeneralSnow everywhere? Pin
Kornfeld Eliyahu Peter11-Feb-17 20:54
professionalKornfeld Eliyahu Peter11-Feb-17 20:54 
GeneralRe: Snow everywhere? Pin
theoldfool12-Feb-17 2:23
professionaltheoldfool12-Feb-17 2:23 
GeneralHappy birthday, Mrs. Nish! Pin
Ravi Bhavnani11-Feb-17 16:33
professionalRavi Bhavnani11-Feb-17 16:33 
GeneralRe: Happy birthday, Mrs. Nish! Pin
BillWoodruff11-Feb-17 18:06
professionalBillWoodruff11-Feb-17 18:06 
GeneralRe: Happy birthday, Mrs. Nish! Pin
Ravi Bhavnani12-Feb-17 6:49
professionalRavi Bhavnani12-Feb-17 6:49 
GeneralRe: Happy birthday, Mrs. Nish! Pin
Nish Nishant12-Feb-17 12:11
sitebuilderNish Nishant12-Feb-17 12:11 
GeneralRe: Happy birthday, Mrs. Nish! Pin
Nish Nishant12-Feb-17 12:11
sitebuilderNish Nishant12-Feb-17 12:11 
GeneralRe: Happy birthday, Mrs. Nish! Pin
Smitha Nishant13-Feb-17 7:35
protectorSmitha Nishant13-Feb-17 7:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Straw Poll

Were you affected by the geomagnetic storms this past weekend?
Communication disruptions, electrified pipes, random unexplained blue-screens in Windows - the list of effects is terrifying.
  Results   494 votes