我有一个效果很好的数据透视查询!
;with PivotData As (
Select KeyField, ColumnName, FieldValue FROM
(SELECT SomeField as KeyField, NameField As ColumnName, DataField as FieldValue
FROM Table1
UNION
SELECT SomeField, NameField, DataField
FROM Table2)
SELECT [List of Fields] FROM PivotData
PIVOT (Max(PivotData.FieldValue) for ColumnName In ([List of Fields])) As P
现在我想将该查询用作存储过程中临时表的源,并且我尝试将查询结果插入临时表的语法都不起作用。
我可以根据结果创建一个临时表吗?如果是这样,怎么做?
谢谢!
莱斯利