I have a table like this,
EmpID EmpName Age DOB
123 user 43 30/06/85
122 user1 42 31/07/86
I need a out put in this format,
Column1 Column2 Column3
EmpID 123 122
EmpName user user1
Age 43 42
DOB 30/06/85 31/07/86
And note the number of columns in table A will keep on increasing, so if I use unpivot to achieve this, I cannot hard code the column names.
See this post on pivots with dynamic columns. http://www.sqlprof.com/blogs/sqldev/default.aspx
btw, for my own bias, I’m assuming SQL server but it would be helpful in future to tag the specific DBMS you’re using