Click here to Skip to main content
15,907,326 members
Home / Discussions / Database
   

Database

 
QuestionHow to Sort this Data Pin
Vimalsoft(Pty) Ltd16-Feb-10 2:32
professionalVimalsoft(Pty) Ltd16-Feb-10 2:32 
AnswerRe: How to Sort this Data Pin
J4amieC16-Feb-10 2:38
J4amieC16-Feb-10 2:38 
GeneralRe: How to Sort this Data Pin
Vimalsoft(Pty) Ltd16-Feb-10 2:45
professionalVimalsoft(Pty) Ltd16-Feb-10 2:45 
AnswerRe: How to Sort this Data Pin
Richard MacCutchan16-Feb-10 2:54
mveRichard MacCutchan16-Feb-10 2:54 
QuestionRe: How to Sort this Data Pin
Chris Meech16-Feb-10 3:07
Chris Meech16-Feb-10 3:07 
AnswerRe: How to Sort this Data Pin
Vimalsoft(Pty) Ltd16-Feb-10 3:25
professionalVimalsoft(Pty) Ltd16-Feb-10 3:25 
AnswerRe: How to Sort this Data Pin
dan!sh 16-Feb-10 6:13
professional dan!sh 16-Feb-10 6:13 
AnswerRe: How to Sort this Data Pin
Jörgen Andersson16-Feb-10 9:06
professionalJörgen Andersson16-Feb-10 9:06 
If this had been Oracle, it would have been a walk in the park:
SELECT *
FROM nodes2
CONNECT BY PRIOR Id = RefParent
START WITH RefParent IS NULL
ORDER SIBLINGS BY Id


If you have SQLServer 2008, this query might work: (Havent tested)
WITH records AS
(
    SELECT
        Id,
        RefParent,
        CONVERT(VARCHAR(MAX), ROW_NUMBER() OVER (ORDER BY Id)) AS thePath
    FROM  nodes2
    WHERE RefParent IS NULL
        UNION ALL
    SELECT
        n.Id,
        n.RefParent,
        r.thePath + '.' + CONVERT(VARCHAR(MAX), ROW_NUMBER() OVER (ORDER BY n.Id)) AS thePath
    FROM records r
    JOIN nodes2 n ON n.RefParent = r.Id
)
SELECT *
FROM records
ORDER BY 
    thePath


There are times when I really hate Oracle, but when you're working with trees it really is SO superior to SqlServer
My postings are a natural product. The slight variations in spelling and grammar enhance their individual character and beauty and are in no way to be considered flaws or defects.

GeneralRe: How to Sort this Data Pin
Vimalsoft(Pty) Ltd16-Feb-10 19:14
professionalVimalsoft(Pty) Ltd16-Feb-10 19:14 
QuestionHow Pin
JustWorking16-Feb-10 1:57
JustWorking16-Feb-10 1:57 
AnswerRe: How Pin
Jörgen Andersson16-Feb-10 2:21
professionalJörgen Andersson16-Feb-10 2:21 
GeneralRe: How Pin
JustWorking16-Feb-10 19:49
JustWorking16-Feb-10 19:49 
GeneralRe: How Pin
Jörgen Andersson16-Feb-10 21:18
professionalJörgen Andersson16-Feb-10 21:18 
QuestionNot sure if this should be in Linq or Database so forgive me. How would I do a left join in linq to sql in c# Pin
tonyonlinux15-Feb-10 9:12
tonyonlinux15-Feb-10 9:12 
AnswerRe: Not sure if this should be in Linq or Database so forgive me. How would I do a left join in linq to sql in c# Pin
Pranay Rana15-Feb-10 19:22
professionalPranay Rana15-Feb-10 19:22 
Questionsql server express installation Pin
Yulianto.14-Feb-10 22:38
Yulianto.14-Feb-10 22:38 
AnswerRe: sql server express installation Pin
Not Active15-Feb-10 1:38
mentorNot Active15-Feb-10 1:38 
GeneralRe: sql server express installation Pin
εїзεїзεїз16-Feb-10 1:41
εїзεїзεїз16-Feb-10 1:41 
GeneralRe: sql server express installation Pin
Not Active16-Feb-10 6:32
mentorNot Active16-Feb-10 6:32 
GeneralRe: sql server express installation Pin
εїзεїзεїз16-Feb-10 6:58
εїзεїзεїз16-Feb-10 6:58 
GeneralRe: sql server express installation Pin
Not Active16-Feb-10 7:10
mentorNot Active16-Feb-10 7:10 
AnswerRe: sql server express installation Pin
εїзεїзεїз16-Feb-10 1:40
εїзεїзεїз16-Feb-10 1:40 
Questionexercize database schema: need advice Pin
mbrownphysics14-Feb-10 14:04
mbrownphysics14-Feb-10 14:04 
QuestionOrderBy Dilema Pin
danyDude14-Feb-10 11:53
danyDude14-Feb-10 11:53 
AnswerRe: OrderBy Dilema Pin
loyal ginger14-Feb-10 14:43
loyal ginger14-Feb-10 14:43 

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.