That is what I thought they @debug was for. When I'm coding I always put in debug statements based off of a debug variable. Makes things so much easier debug and you don't have to remove them to move it into production.
1 Like
Here are a couple of articles on the subject of "Crosstabs and Pivots". The first explains what they are, how they work, and which can be made to perform better using a wonderful thing known as "pre-aggregation" and contains code to easily duplicate the performance tests. The second article explains how to construct dynamic Crosstabs quite easily.
http://www.sqlservercentral.com/articles/T-SQL/63681/
http://www.sqlservercentral.com/articles/Crosstab/65048/
Jason's good code uses the CROSTAB method with the (2012 kicker known as CONCAT), which is the method I prefer.
1 Like