TSQL Challenge 15 - Solution by Beth Seefelt



-- File Name: Beth_Seefelt_TSQLChallenge_15.sql
select Row, [1],[2],[3],[4],[5],[6],[7],[8],[9]
from
(
select Row
     , Col
     , case when Row % Col = 0 then 'x' else '' end x
  from @Rows
  cross join @Cols
) dtbl
pivot
(
    max(x)
    for Col in ([1],[2],[3],[4],[5],[6],[7],[8],[9]) 
 ) as p  
order by Row