calculate balance sheet with fastest algorithem : I am implementing accounting software,
in calculating balance sheet of the Hirarchical self referenced topics please let me know the fastest algorithem , in following is my tables:

    --Topics table
    TopicID nvarchar(50) -- is Parent Field
    ParentID nvarchar(50) -- is Child Field
    Description nvarchar(512) 
    ------------DocumentDetal table
    DocumentNumber nvarchar(50)
    TopicFK nvarchar(50)  
    Debit decimal(18,0)
    Credit decimal(18,0)
    ------------
two table are related with TopicID and TopicFK columns , please let me know how I can calculate balance sheet by sql stored proc ???