advanced query – help needed | SQL Server Performance Forums
SQL Server Performance Forum – Threads Archive
advanced query – help neededI need a rather advanced query that transforms data from a table to a specified format. I am providing a screenshot of the initial and desired formats. Oh, and there are several thousands of records here, so any cursors enumerating over 100 times cannot be used due to performance. Original table: Desired result:
Note that ‘characteristic x name’ is not the same for each item, as the number of characteristics can be different per each item. The order of characteristics is not important, but if an item has 3 characteristics, they must occupy spots 1 through 3. Myself I was only able to do it with cursors (slow), my colleague did it with clr/.net (not recommended). Many thanks in advance.
Seriously this doesn’t seem to be a task for the database engine. It should rather be handled at the presentation layer. It can be done in T-SQL with dynamic SQL and pivoting, but it be better not.