原表:转过的表:
代码:
declare @sql varchar(1000) set @sql = 'select AssetRecordId ' select @sql = @sql + ' , max(case ExtendName when ''' + ExtendName + ''' then ExtendValue else null end) [' + ExtendName + ']' from (select distinct ExtendName from dbo.AssetExtend where AssetRecordId=61) as a set @sql = @sql + ' from dbo.AssetExtend where AssetRecordId=61 group by AssetRecordId' exec(@sql)