Are you using SQL Server 2005 for relational storage? In that case, you
could use the new TSQL PIVOT clause to create a fact table view with a
column for each question - without changing the original table, like:
[1] AS Q1AnsID, [2] AS Q2AnsID, [3] AS Q3AnsID
FROM
(SELECT AutoID, PanelID, QuestionID, AnswerID
FROM PanelData) p
PIVOT
(
MAX(AnswerID)
FOR QuestionID IN
([1], [2], [3])
) AS pvt
http://msdn2.microsoft.com/en-US/lib...0(SQL.90).aspx
You can use the PIVOT and UNPIVOT relational operators to manipulate a
table-valued expression into another table. PIVOT rotates a table-valued
expression by turning the unique values from one column in the
expression into multiple columns in the output, and performs
aggregations where necessary on any remaining column values that are
desired in the final output. UNPIVOT performs the opposite operation to
PIVOT by rotating columns of a table-valued expression into column
values.
...
- Deepak
Deepak Puri
Microsoft MVP - SQL Server
*** Sent via Developersdex http://www.developersdex.com ***