Sql server dynamic pivot with dynamic fields type
问题 I need to build a dynamic pivot table on Sql Server 2005 and I found several excellent answers on how to do it, but I have an extra requirement to implement: dynamic field type . This is my data structure CREATE TABLE [dbo].[MyData]( [Key] [char](12) NOT NULL, [AttributeName] [char](3) NOT NULL, [AttributeValue] [char](40) NOT NULL) This is the definition of types. CREATE TABLE [dbo].[Attributes]( [AttributeName] [char](3) NOT NULL, [CastTo] [char](10) NOT NULL, [Size] int NULL, [Precision]