Knowledge: SQL to Iterate through Child Data Room items
Back
    Title*SQL to Iterate through Child Data Room items
    ManualReporting
    Created20/02/2018
    DetailDECLARE @ItemID as int = 7423 DECLARE @AllRecords as bit = 0 DECLARE @ApplicationID as int = 1147 IF (@AllRecords = 1) BEGIN IF OBJECT_ID('tempdb..#TempClaims') IS NOT NULL DROP TABLE #TempClaims SELECT * INTO #TempClaims FROM ClaimClaimRelationships WHERE ParentClaimID = @ItemID Declare @Id int WHILE EXISTS(SELECT * FROM #TempClaims) Begin Select Top 1 @Id = Id From #TempClaims SET @ItemID = (Select ChildClaimID FROM #TempClaims WHERE Id=@ID) SELECT * FROM Claims WHERE ID=@ItemID Delete #TempClaims Where Id = @Id End Drop Table #TempClaims END ELSE BEGIN SELECT * FROM Claims WHERE ID=@ItemID AND ApplicationID=@ApplicationID END
    ManualManual Level TwoManual Level Three
    AdministrationData ActionsSQL
    Privacy Policy
    Cookies help us to improve your user experience. By using this site you consent to cookies being stored on your device. Read more...
    View or hide all system messages