• Hi guys thanks, the issue is resolved. I just taken the value for @columname inside while loop. actually i was taking @column name value from @leantemp temporary table. Now i have taken the value inside while loop, its working now. I dont know whts the exact problem.

    Both the methods are fetching same column name only. But the issue is resolved now.