get parenrs and childs based on id my Data
    TradeID Commodity   GeneratedFrom
    32839   CPO             NULL
    32840   Hard Stearin    NULL
    32841   PFAD            32839
    32842   RBDPO           32839
    32843   CPO             NULL
    32844   Olein           32842
    32845   Stearin         32842
    32846   RBDPO           NULL
    32847   Hard Stearin    32845
    32848   PMF             32845

when give the trade id then return patents and childs like when i give Tradeid 32845
in above data Genrated from is patrent Id and which tradeid has Grerated from they are childs.
i want below result
     TradeID
      32845
      32847 
      32848 
      32842
      32839
You can use a recursive CTE similar to the following to get the whole ancestor list (parents and children) for a given TradeID:
WITH RecursiveCTE_Children AS
(
    SELECT GeneratedFrom, TradeID
    FROM MyData

    UNION ALL

    SELECT RC.TradeID AS GeneratedFrom, MD.TradeID
    FROM RecursiveCTE_Children AS RC 
    INNER JOIN MyData AS MD
        ON RC.TradeID = MD.GeneratedFrom
),
RecursiveCTE_Ancestors AS
(
    SELECT GeneratedFrom, TradeID
    FROM MyData

    UNION ALL

    SELECT MD.GeneratedFrom, RC.GeneratedFrom AS TradeID
    FROM RecursiveCTE_Ancestors AS RC 
    INNER JOIN MyData AS MD
        ON RC.GeneratedFrom = MD.TradeID
)

SELECT TradeID
FROM RecursiveCTE_Children
WHERE GeneratedFrom = 32845

UNION

SELECT GeneratedFrom
FROM RecursiveCTE_Ancestors
WHERE TradeId = 32845