Hmm mein Ergebniss:
SQL-Code:
Declare @Result Table ( Id Int )
Declare @Ids Table ( Id Int )
Declare @Temp Table ( Id Int )
Insert Into @Result Select Id
From swgResourceClass
Where Name = 'Inorganic'
Insert Into @Ids Select Id
From swgResourceClass
Where Name = 'Inorganic'
While ( Select Count( Id ) From swgResourceClass Where ParentID In ( Select Id From @Ids ) ) <> 0
Begin
Delete From @Temp
Insert Into @Temp Select Id From @Ids
Delete From @Ids
Insert Into @Ids Select Id
From swgResourceClass Where ParentID In ( Select Id From @Temp )
Insert Into @Result Select Id
From swgResourceClass Where ParentID In ( Select Id From @Temp )
End
Select * From swgResourceClass Where Id In ( Select Id From @Result )
Das geht soweit, aber vielleicht hat ja wer eine Idee wie es besser geht
Bye Christian