SQL Server Performance

advanced query - help needed

Discussion in 'SQL Server 2008 T-SQL Performance Tuning' started by pl800, Dec 7, 2011.

  1. pl800 New Member

    I 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:

    Original table.png

    Desired result:

    Desired result.png
    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.
  2. FrankKalis Moderator

    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.

Share This Page