November 2, 2007 at 3:56 pm
I have a problem with converting Rows to Column Names. I have created a table (CustomFields) where users can define user defined fields for a form. The structure of the table is (CustomFieldId, FieldType, FieldName). CustomFieldId is Primary Key. FieldType is the type of the field where user can select numeric, text, datetime etc. and The FieldName will become labels for a formview and as columns when shown in a gridview.
I have a value table where I have 3 columns CustomValueId, CustomFieldId, CValue. This table has a foreign key relationship with CustomFields table. When user types in a value for a field this table will store that. Now is there anyway I can write a select statement that would give me a resultset with the CustomFieldName as the column names and the CValue as it's corresponding values.
I know I can write C# code to add columns in a datatable but I was wondering if it can be done in some cool way with T-SQL
Thanks in advance
himadri
November 2, 2007 at 8:45 pm
You don't appear to have anything to relate the given values to logical rows... have you posted all the columns that appear in these tables?
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply