• Having two nested WHILE loops is likely to be a performance killer. See if you can rewrite them into a set-based operation. As Bhuvnesh mentions, please post table DDL and sample data if you need any further help.

    John