Skip to main content
Submitted

Transpose a table

  • December 12, 2018
  • 5 replies
  • 0 views

Forum|alt.badge.img

In my projects, it often happens that I get spreadsheets from Excel and need to transpose them first. At the moment I do this over a complex T-SQL Script. A simplification feature would be very desirable.

5 replies

Forum|alt.badge.img
  • Participating Frequently
  • December 13, 2018

Do you mean PIVOT? I agree..

This (6 year old) post might be related:

https://support.timextender.com/hc/en-us/community/posts/205682263-Support-PIVOT-and-UNPIVOT


  • New Participant
  • December 13, 2018

The "Table insert" feature can maybe help with this ?


Forum|alt.badge.img
  • Author
  • New Participant
  • December 13, 2018

Hi Bas,

Correct. I mean Pivot and Unpivot.


Forum|alt.badge.img
  • Known Participant
  • December 14, 2018

Kurt is correct that a pivot can be approximated in many cases by using repeated table inserts.  Another way to handle that is to combine table inserts and lookups if you need to aggregate certain fields.  You can also use a custom insert with the PIVOT command, although building and maintaining custom code is a pain. 

I have never really liked PIVOT and UNPIVOT, and there are lots of complaints about their functionality and performance vs. other more modern techniques for getting the same result.  These options include interesting tricks with XML, dynamic SQL, and JSON. 

I also recommend pivoting data in the front end wherever possible, as they are optimized for that kind of function.  Of course, if you need the data pivoted for ETL stuff, and can't get the data properly pivoted before it reaches you, there may not be much of an option.  


Forum|alt.badge.img
  • Known Participant
  • June 3, 2020

This is just a necessity for an ETL layer. Any progress on this?