SELECT categoryproductid, [0] AS p0, [1] AS p1, [2] AS p2, [3] AS p3, [4] AS p4, [5] AS p5, [6] AS p6, [7] AS p7, [8] AS p8, [9] AS p9
FROM (SELECT categoryproductid, sequence, propertyname
FROM CategoryProductsProperty) AS CategoryProductsProperty PIVOT (max(CategoryProductsProperty.propertyname) FOR sequence IN ([0], [1],
[2], [3], [4], [5], [6], [7], [8], [9])) AS pvt
FROM (SELECT categoryproductid, sequence, propertyname
FROM CategoryProductsProperty) AS CategoryProductsProperty PIVOT (max(CategoryProductsProperty.propertyname) FOR sequence IN ([0], [1],
[2], [3], [4], [5], [6], [7], [8], [9])) AS pvt