SQL Server Performance

Transpose Columns to Rows in SQL Table

Discussion in 'SQL Server 2008 General DBA Questions' started by sharmadipak, May 17, 2010.

  1. sharmadipak New Member

    Friends,

    I have a SQL table in which I have data in 35 columns wherein from 24th columns which repeats 12 months twice like FJAN, FFEB, FMAR... till FDEC and then AJAN, AFEB, AMAR.... till ADEC. In the first 11 columns the data has respective descriptions for these months. What I need is to transpose data for all the 35 columns into rows where I need new columns like Months & Values. In months column I need to shows FJAN, FFEB, FMAR and so on and then numeric value in Values Columns. Similarly I need another Months & Values column where I need to show AJAN, AFEB, AMAR and in values column values for that month. Please suggest a SQL query to transpose this data.

    I have upload the same excel file in which there are 2 sheets showing the data state now and what is required....
    File Path : http://rapidshare.com/files/388625763/Sample.xlsx.html
    Please help me out friends....

    Thanks in Advance...
    Deepak Sharma
  2. Adriaan New Member

    Looks like a translation table? Normalization rules suggest that you have one column for the month number, one for the language, and one for the local name of the month.
    Having a separate column per language means you have to execute a different query each time. With a normalized table, it's the same query each time, just with different criteria.

Share This Page