Skip to content
Advertisement

Syntax issue with CTE to Pivot function

I’m having a problem getting syntax correct from variables to CTE to Pivot. I’m capturing sp_whoisactive to a table and am now aggregating CPU and Duration by Region. I then want to pivot those results for easy charting in Excel. My workaround was to output to a #Temp table which causes issues in SSIS when attempting to output to sheets of Excel.

I pared down the CASE statement for brevity. There are approximately 30 regions.

How do I wrap this in CTE so I can pivot using start and end variable dates and eliminate #Temp tables?

Advertisement

Answer

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement