Click here to Skip to main content
16,006,001 members
Home / Discussions / Database
   

Database

 
GeneralAccessing SQL Server without static IP Pin
johnie836-Dec-04 18:44
johnie836-Dec-04 18:44 
Generalprogress Pin
Yulianto.6-Dec-04 15:45
Yulianto.6-Dec-04 15:45 
GeneralRe: progress Pin
Dave Kreskowiak10-Dec-04 9:50
mveDave Kreskowiak10-Dec-04 9:50 
GeneralInvoke oracle job remotley Pin
RobNicolson6-Dec-04 4:44
RobNicolson6-Dec-04 4:44 
QuestionBLOBs: How to insert/store and get/retrieve an object? Pin
Rafferty Uy5-Dec-04 13:58
Rafferty Uy5-Dec-04 13:58 
AnswerRe: BLOBs: How to insert/store an object? Pin
Steve S6-Dec-04 1:32
Steve S6-Dec-04 1:32 
GeneralRe: BLOBs: How to insert/store an object? Pin
Rafferty Uy6-Dec-04 13:18
Rafferty Uy6-Dec-04 13:18 
GeneralRe: BLOBs: How to insert/store an object? Pin
Steve S7-Dec-04 1:30
Steve S7-Dec-04 1:30 
AnswerRe: BLOBs: How to insert/store and get/retrieve an object? Pin
Rafferty Uy8-Dec-04 17:01
Rafferty Uy8-Dec-04 17:01 
GeneralADO .NET and Excel... :( :( HELP!! Pin
fadee4-Dec-04 10:15
fadee4-Dec-04 10:15 
GeneralString array to Oracle procedure from VB.Net Pin
Santhimurthy3-Dec-04 22:05
Santhimurthy3-Dec-04 22:05 
QuestionCan anyone help me with this one? Pin
Suresh Prasad3-Dec-04 10:40
Suresh Prasad3-Dec-04 10:40 
AnswerRe: Can anyone help me with this one? Pin
Mike Ellison3-Dec-04 11:13
Mike Ellison3-Dec-04 11:13 
GeneralRe: Can anyone help me with this one? Pin
Suresh Prasad3-Dec-04 11:29
Suresh Prasad3-Dec-04 11:29 
GeneralRe: Can anyone help me with this one? Pin
Mike Ellison3-Dec-04 11:48
Mike Ellison3-Dec-04 11:48 
GeneralRe: Can anyone help me with this one? Pin
Suresh Prasad3-Dec-04 11:57
Suresh Prasad3-Dec-04 11:57 
GeneralUploading Large numbers of records Pin
mjackson113-Dec-04 8:07
mjackson113-Dec-04 8:07 
GeneralRe: Uploading Large numbers of records Pin
Alex Korchemniy4-Dec-04 16:56
Alex Korchemniy4-Dec-04 16:56 
GeneralRe: Uploading Large numbers of records Pin
mjackson118-Dec-04 9:42
mjackson118-Dec-04 9:42 
GeneralADO.NET columns are magic numbers.. Pin
giorgos_gr3-Dec-04 5:09
giorgos_gr3-Dec-04 5:09 
GeneralSQL Tree Hierarchy Problem Pin
Dirk Kok2-Dec-04 22:24
sussDirk Kok2-Dec-04 22:24 
Hi
Please help me out here with some hierarchies. It’s blowing my mind.
Here’s the table…

CREATE TABLE [dbo].[Tree] (
[ID] [int] IDENTITY (1, 1) NOT NULL ,
[ParentID] [int] NULL ,
[Lineage] [varchar] (50) NULL ,
[Name] [varchar] (50) NOT NULL
) ON [PRIMARY]
GO


Here’s some data…

SET IDENTITY_INSERT Tree ON

INSERT INTO Tree (ID, ParentID, Lineage, Name) VALUES (1, NULL, '.0001.', 'Root')
INSERT INTO Tree (ID, ParentID, Lineage, Name) VALUES (2, 1, '.0001.0002.', 'I')
INSERT INTO Tree (ID, ParentID, Lineage, Name) VALUES (3, 1, '.0001.0003.', 'H')
INSERT INTO Tree (ID, ParentID, Lineage, Name) VALUES (4, 1, '.0001.0004.', 'G')
INSERT INTO Tree (ID, ParentID, Lineage, Name) VALUES (5, 2, '.0001.0002.0005.', 'F')
INSERT INTO Tree (ID, ParentID, Lineage, Name) VALUES (6, 2, '.0001.0002.0006.', 'E')
INSERT INTO Tree (ID, ParentID, Lineage, Name) VALUES (7, 2, '.0001.0002.0007.', 'D')
INSERT INTO Tree (ID, ParentID, Lineage, Name) VALUES (8, 4, '.0001.0004.0008.', 'C')
INSERT INTO Tree (ID, ParentID, Lineage, Name) VALUES (9, 4, '.0001.0004.0009.', 'B')
INSERT INTO Tree (ID, ParentID, Lineage, Name) VALUES (10, 3, '.0001.0003.0010.', 'A')

SET IDENTITY_INSERT Tree OFF

You have the above tree data. You can ignore the lineage if you don’t want to work with it.


There problem is as follows…


Please sort the tree nodes according to the hierarchy, BUT the nodes must also be in ALPHABETICAL order.


So “SELECT * FROM Tree ORDER BY Lineage” will look like so…


Root
I
F
E
D
H
A
G
C
B

But I need it to be sorted in that hierarchy but also alphabetically like so

Root
G
B
C
H
A
I
D
E
F


Can someone figure this out for me please?

Regards
Dirk









GeneralRe: SQL Tree Hierarchy Problem Pin
Michael Potter3-Dec-04 4:34
Michael Potter3-Dec-04 4:34 
GeneralRe: SQL Tree Hierarchy Problem Pin
Chris Meech3-Dec-04 6:44
Chris Meech3-Dec-04 6:44 
GeneralStored Proc and SqlDataAdapter Pin
ccosser2-Dec-04 22:03
ccosser2-Dec-04 22:03 
GeneralAttaching a database to MSDE Pin
mattie202-Dec-04 20:31
mattie202-Dec-04 20:31 

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.