lundi 11 juillet 2016

Cast column name to specific character during Pivot table creation - SQL

I have a table test which has a column Label. It has Data which is longers than 50 characters in length.

When I create a pivot table from the 'test' table , it uses those long charactered data as column name.

My requirement is to user cast function to limit the column names to say 26 characters.

I use the below script , but it doesnt work as desired.

create table V_Test as
select * from 
    (select * from Test) x
pivot (sum(Average) for Label in (
    S03_CreatePlansdadsada,
    S03_CreatePlan_T01_NavigateTosdsadsaded,
    S03_CreatePlan_T03_abcdefgmanagementsdasda,
    S03_CreatePlan_T16_SetStatusToOngoingasdasda,
    S03_CreatePlan_T17_Ldsdssdadsadas                           
)
) p

Thanks in advance for the help

Aucun commentaire:

Enregistrer un commentaire