寻找优雅(或任何)解决方案将列转换为行.
这是一个例子:我有一个包含以下模式的表:
[ID] [EntityID] [Indicator1] [Indicator2] [Indicator3] ... [Indicator150]
Run Code Online (Sandbox Code Playgroud)
以下是我想得到的结果:
[ID] [EntityId] [IndicatorName] [IndicatorValue]
Run Code Online (Sandbox Code Playgroud)
结果值将是:
1 1 'Indicator1' 'Value of Indicator 1 for entity 1'
2 1 'Indicator2' 'Value of Indicator 2 for entity 1'
3 1 'Indicator3' 'Value of Indicator 3 for entity 1'
4 2 'Indicator1' 'Value of Indicator 1 for entity 2'
Run Code Online (Sandbox Code Playgroud)
等等..
这有意义吗?您对在T-SQL中查看的位置以及如何完成它有什么建议吗?