Click here to Skip to main content
15,899,026 members
Home / Discussions / Database
   

Database

 
GeneralRe: Parent-children Listing Pin
Ali Al Omairi(Abu AlHassan)11-Mar-11 8:45
professionalAli Al Omairi(Abu AlHassan)11-Mar-11 8:45 
GeneralRe: Parent-children Listing Pin
Chris Meech11-Mar-11 9:04
Chris Meech11-Mar-11 9:04 
GeneralRe: Parent-children Listing Pin
Ali Al Omairi(Abu AlHassan)11-Mar-11 9:09
professionalAli Al Omairi(Abu AlHassan)11-Mar-11 9:09 
GeneralRe: Parent-children Listing Pin
Chris Meech11-Mar-11 9:41
Chris Meech11-Mar-11 9:41 
AnswerRe: Parent-children Listing Pin
Wendelius11-Mar-11 9:16
mentorWendelius11-Mar-11 9:16 
GeneralRe: Parent-children Listing Pin
Ali Al Omairi(Abu AlHassan)11-Mar-11 9:26
professionalAli Al Omairi(Abu AlHassan)11-Mar-11 9:26 
GeneralRe: Parent-children Listing Pin
Wendelius11-Mar-11 12:02
mentorWendelius11-Mar-11 12:02 
AnswerRe: Parent-children Listing Pin
i.j.russell11-Mar-11 23:36
i.j.russell11-Mar-11 23:36 
CREATE TABLE #data
(
	ID INT NOT NULL,
	PID INT NULL,
	VALUE VARCHAR(20) NOT NULL
);

INSERT INTO #data
(ID, PID, VALUE)
VALUES
(1, NULL, 'node 1'),
(4, 1, 'node 1/1'),
(6, 4, 'node 1/1/1'),
(5, 1, 'node 1/2'),
(7, 1, 'node 1/3'),
(2, NULL, 'node 2'),
(3, NULL, 'node 3'),
(8, 3, 'node 3/1');

WITH MyCTE AS
(
	SELECT ID, PID, VALUE, 0 AS [LEVEL]
	FROM #data
	WHERE PID IS NULL
	UNION ALL
	SELECT D.ID, D.PID, D.VALUE, [LEVEL] + 1
	FROM MyCTE M
		JOIN #data D
			ON D.PID = M.ID
)
SELECT ID, PID, VALUE, [LEVEL]
FROM MyCTE;

DROP TABLE #data;

GeneralRe: Parent-children Listing Pin
Ali AlOmairi (TJIC)12-Mar-11 6:46
Ali AlOmairi (TJIC)12-Mar-11 6:46 
QuestionHow to make this Pin
Nath10-Mar-11 23:59
Nath10-Mar-11 23:59 
AnswerRe: How to make this Pin
musefan11-Mar-11 0:16
musefan11-Mar-11 0:16 
GeneralRe: How to make this Pin
Nath11-Mar-11 0:28
Nath11-Mar-11 0:28 
GeneralRe: How to make this Pin
musefan11-Mar-11 0:44
musefan11-Mar-11 0:44 
AnswerRe: How to make this [modified] Pin
Ali Al Omairi(Abu AlHassan)11-Mar-11 8:02
professionalAli Al Omairi(Abu AlHassan)11-Mar-11 8:02 
GeneralRe: How to make this Pin
Klaus-Werner Konrad16-Mar-11 8:10
Klaus-Werner Konrad16-Mar-11 8:10 
GeneralRe: How to make this Pin
Ali Al Omairi(Abu AlHassan)16-Mar-11 21:02
professionalAli Al Omairi(Abu AlHassan)16-Mar-11 21:02 
GeneralRe: How to make this Pin
Klaus-Werner Konrad17-Mar-11 6:54
Klaus-Werner Konrad17-Mar-11 6:54 
GeneralRe: How to make this Pin
Ali Al Omairi(Abu AlHassan)17-Mar-11 11:19
professionalAli Al Omairi(Abu AlHassan)17-Mar-11 11:19 
GeneralRe: How to make this Pin
Klaus-Werner Konrad17-Mar-11 12:39
Klaus-Werner Konrad17-Mar-11 12:39 
GeneralRe: How to make this Pin
Ali Al Omairi(Abu AlHassan)17-Mar-11 12:45
professionalAli Al Omairi(Abu AlHassan)17-Mar-11 12:45 
AnswerRe: How to make this Pin
Klaus-Werner Konrad16-Mar-11 8:25
Klaus-Werner Konrad16-Mar-11 8:25 
GeneralRe: How to make this Pin
Ali Al Omairi(Abu AlHassan)17-Mar-11 11:43
professionalAli Al Omairi(Abu AlHassan)17-Mar-11 11:43 
QuestionConverting last N columns to rows in sql server Pin
sumit703410-Mar-11 17:18
sumit703410-Mar-11 17:18 
AnswerRe: Converting last N columns to rows in sql server Pin
Mycroft Holmes10-Mar-11 18:28
professionalMycroft Holmes10-Mar-11 18:28 
GeneralRe: Converting last N columns to rows in sql server Pin
sumit703410-Mar-11 18:36
sumit703410-Mar-11 18:36 

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.