Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
learntsql
524 Posts |
Posted - 2009-08-03 : 03:10:00
|
| Hi All,--Unpivot the table.SELECT VendorID, Employee, OrdersFROM (SELECT VendorID, Emp1, Emp2, Emp3, Emp4, Emp5 FROM pvt) pUNPIVOT (Orders FOR Employee IN (Emp1, Emp2, Emp3, Emp4, Emp5))AS unpvtIn above Query how can i dynamically get the Emp1,Emp2,Emp3.... columns which are mentioned in UNPIVOT Clause and SELECT clause from table itself.Because my table structure may change.Is it possible? If not if that is the requirement what are the alternative ways.Plz tell me. |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
|
|
learntsql
524 Posts |
Posted - 2009-08-03 : 03:22:23
|
| Thanks for reply,but it slows down the performanceand we have security issues also right. |
 |
|
|
learntsql
524 Posts |
Posted - 2009-08-03 : 03:26:19
|
| Oh Sorry khtan,I will go through once that link. |
 |
|
|
|
|
|
|
|