>The query sp did run with correct results.
>Microsoft has room for imperfect like me.
I'm really surprised.
>
>UPDATE #db_ledger SET balance =
> (SELECT SUM(glamnt) FROM #db_ledger d WHERE d.gldt < #db_ledger.gldt)
>
>There can be more than one record on same day so the update function I think may not work.
As long as the time component is included in gldt, there shouldn't be a problem.
>Does the extra update for the balance have any overhead over the query time.
>(How much overhead for 10000 records approx.) How can I measure it.
>
>Is there any other way to frame the same query without the temp table & can the balance updation be set as a contraint over the table.
There are no constraint that provides a means to maintain calculated data. You could do it with a trigger but you still must have a way to serialize the transaction records.
-Mike