Kindly refer the below link, It is **T-Sql Server 2005** question. for adding dynamic columns in a temporary table. Here 2 temp tables are there as tabl1 and table2 and result is in "output table". here my rows are getting converted in columns. Using plain pivot I am not able to achive this.One Person from this forum only has helped me but now the reqiriment has changed now. **Kindly see the below link.**
http://social.msdn.microsoft.com/Forums/en-US/transactsql/thread/ffc715fb-41f6-49f6-bfd6-8471cb2c73ff
Submitted under: Microsoft SQL Server · TSQL · · ·
Duplicate thread, cross posted from here. Closing..