Recent PostsRecent Posts Popular TopicsPopular Topics
 Home Search Members Calendar Who's On

 Manipulate Horizontal Hierarchy with UNPIVOT Rate Topic Display Mode Topic Options
Author
 Message
 Posted Thursday, December 20, 2012 3:45 AM
 Old Hand Group: General Forum Members Last Login: Tuesday, December 15, 2015 8:06 AM Points: 313, Visits: 194
 Comments posted to this topic are about the item Manipulate Horizontal Hierarchy with UNPIVOT
Post #1398888
 Posted Tuesday, January 15, 2013 11:37 PM
 Hall of Fame Group: General Forum Members Last Login: Wednesday, February 24, 2016 6:28 AM Points: 3,977, Visits: 6,431
 You might want to look into using the CROSS APPLY VALUES approach to UNPIVOT (see the first article in my signature links). I find it much more readable that multiple UNPIVOTs and it seems to perform better as well. My mantra: No loops! No CURSORs! No RBAR! Hoo-uh!My thought question: Have you ever been told that your query runs too fast?My advice:INDEXing a poor-performing query is like putting sugar on cat food. Yeah, it probably tastes better but are you sure you want to eat it?The path of least resistance can be a slippery slope. Take care that fixing your fixes of fixes doesn't snowball and end up costing you more than fixing the root cause would have in the first place.Need to UNPIVOT? Why not CROSS APPLY VALUES instead?Since random numbers are too important to be left to chance, let's generate some!Learn to understand recursive CTEs by example.Splitting strings based on patterns can be fast!My temporal SQL musings: Calendar Tables, an Easter SQL, Time Slots and Self-maintaining, Contiguous Effective Dates in Temporal Tables
Post #1407622
 Posted Tuesday, April 30, 2013 9:25 PM
 Old Hand Group: General Forum Members Last Login: Tuesday, December 15, 2015 8:06 AM Points: 313, Visits: 194
 Thanks!, good stuff! I will practice your technic!Cheers!
Post #1448295
 Posted Tuesday, May 3, 2016 7:01 AM
 SSCrazy Eights Group: General Forum Members Last Login: Yesterday @ 6:33 AM Points: 8,183, Visits: 830
 Thanks for the script.
Post #1782873
 Posted Tuesday, May 3, 2016 7:01 AM
 SSCrazy Eights Group: General Forum Members Last Login: Yesterday @ 6:33 AM Points: 8,183, Visits: 830
 dwain.c (1/15/2013)You might want to look into using the CROSS APPLY VALUES approach to UNPIVOT (see the first article in my signature links). I find it much more readable that multiple UNPIVOTs and it seems to perform better as well.Thanks for the extra tip.
Post #1782874

 Permissions