1

Table : MyConfigurations

ID  ConfigName  Property              Value             Scope  
--------------------------------------------------------------------------
 9  AddMbrInfo  ADDMBRINFO            C:\ROOT\F1.dtl    Package  
10  AddMbrInfo  ADDMBRINFO2           C:\ROOT\F2.dtl    Package  
11  AddMbrInfo  EmailFromAddress      123@abc.com       Package

Desired Output:

ConfigName           ADDMBRINFO         ADDMBRINFO2           EmailFromAddress  
------------------------------------------------------------------------------
Daily_DFWL_Info_new  C:\ROOT\F1.dtl     C:\ROOT\F2.dtl        123@abc.com  

I was trying to write transpose of row to columns depending upon the rows.

How can I write query to transpose dynamically if rows in the table increases?

Eg: if Property column has few more columns in future, I need to build the query dynamically with out hardcoding.

Taryn
  • 242,637
  • 56
  • 362
  • 405
  • Search for [`sql-server` and `pivot`](http://stackoverflow.com/search?q=sql-server+pivot) results in 2426 hits - I'm pretty sure **at least ONE of those** will fit your needs! – marc_s Oct 06 '14 at 12:32
  • 1
    Possibly the most asked sql question. Google "SQL Pivot". – Tab Alleman Oct 06 '14 at 12:32

0 Answers0