• You can try this. It looks like the results you're after but why you'd want such bizarre results eludes me (enlightnment requested :-)).

    SELECT PntKey=ISNULL(PntKey, Cd2PntKey)

    ,PntQty=CASE WHEN n1 = 1 THEN PntQty END

    ,FromDate1, ToDate1

    ,FromDate2=Cd2FromDate, ToDate2=Cd2ToDate

    FROM (

    SELECT p.PntKey

    ,p.PntQty

    ,FromDate1=Cd1FromDate

    ,ToDate1=Cd1ToDate

    ,n1=ROW_NUMBER() OVER (PARTITION BY PntKey ORDER BY Cd1Key)

    FROM #Parent p

    RIGHT JOIN #Child1 c1 ON p.PntKey = c1.Cd1PntKey) a

    FULL JOIN (

    SELECT Cd2Key, Cd2PntKey, Cd2FromDate, Cd2ToDate

    ,n2=ROW_NUMBER() OVER (PARTITION BY Cd2PntKey ORDER BY Cd2Key)

    FROM #Child2) c2

    ON a.PntKey = c2.Cd2PntKey AND a.n1 = c2.n2

    ORDER BY PntKey


    My mantra: No loops! No CURSORs! No RBAR! Hoo-uh![/I]

    My thought question: Have you ever been told that your query runs too fast?

    My advice:
    INDEXing a poor-performing query is like putting sugar on cat food. Yeah, it probably tastes better but are you sure you want to eat it?
    The path of least resistance can be a slippery slope. Take care that fixing your fixes of fixes doesn't snowball and end up costing you more than fixing the root cause would have in the first place.

    Need to UNPIVOT? Why not CROSS APPLY VALUES instead?[/url]
    Since random numbers are too important to be left to chance, let's generate some![/url]
    Learn to understand recursive CTEs by example.[/url]
    [url url=http://www.sqlservercentral.com/articles/St