mpradeesh,
It would help if you could provide some sample data to illustrate exactly what you want to happen.
There are a number of alternatives.
Be aware though that using the OUTPUT clause to directly insert rows to a permanent table has a few restrictions. Specifically, the destination table cannot:
Those restrictions often make it impossible to use the OUTPUT clause in this way. If the number of rows is small, consider using a table variable as an intermediate step. Even if those restrictions do not apply, you should know that your code will break if, for example, someone adds a trigger to the table at any point in the future.
The sample data would help us to give you an accurate solution.
Paul
Paul White
SQLPerformance.com
SQLkiwi blog
@SQL_Kiwi