Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.
Declare @strSQL varchar(max) DECLARE @cols varchar(2000) -- Assigning Y here just for demo purposes, populate however you want. Declare @UTILIZED char(1) = 'Y' SELECT @cols = STUFF(( SELECT DISTINCT '],[' + cast(Level3 as varchar) From PPS_SKU_UTILIZATION ORDER BY 1 FOR XML PATH('') ), 1, 2, '') + ']' set @strSQL = 'select YEAR, MONTH, ' + @cols + ' from ( select YEAR, MONTH, Level3, UTILIZED from PPS_SKU_UTILIZATION WHERE UTILIZED=''' + @UTILIZED + ''') o pivot (COUNT(UTILIZED) for Level3 in (' + @cols + '))p ORDER BY MONTH' exec(@strSQL)
|SYNTAX PROBLEM -- adding another column into the stored procedure output||30||38|
|Gettg error - Please help Msg 252, Level 16, State 1, Line 1||3||28|
|TSQL - How to declare table name||26||28|
|sql 2008 how to table join||2||12|
Join the community of 500,000 technology professionals and ask your questions.
Connect with top rated Experts
16 Experts available now in Live!