当我在SQL管理工作室中执行它时,我的SQL查询工作正常但在SSIS包中执行时抛出以下错误。有什么建议吗?
**单击语法的构建查询时 - 显示
不支持PIVOT SQL构造或语句 案例1:
SELECT listid,
[1]
FROM (SELECT listid,
val,
[order]
FROM gmt_listsvals) P
PIVOT (Max (val)
FOR [order] IN ([1])) AS pvt
案例2:
SELECT comb_id, [orgunit], [time], [gender], [jobcategory], [ethnicity], [gradegroup], [regiongeo], [emplclass], operatorid, seq_id, sequance_name, listid
FROM (SELECT C.comb_id, dim_name, V.operatorid,V.seq_id, V.listid, dim_value, S.sequance_name
FROM gmt_combinationsflat C
JOIN gmt_valuesflat V ON C.comb_id = V.comb_id
JOIN gmt_rangeseq S ON V.seq_id = S.seq_id
JOIN gmt_dimensions D ON C.dim_id = D.dim_id
WHERE C.kpi_id = 9 AND C.last = 1) P
PIVOT (Max(dim_value) FOR dim_name IN ( [ORGUNIT ], [Time ], [Gender ], [JobCategory ], [Ethnicity ], [GradeGroup ], [RegionGeo ], [EmplClass ] ) ) AS pvtt
HRESULT异常:0xC0202009错误...:SSIS错误代码 DTS_E_OLEDBERROR。发生OLE DB错误。错误代码: 0x80040E21。 OLE DB记录可用。来源:" Microsoft SQL Server Native Client 11.0" Hresult:0x80040E21描述: "多步OLE DB操作生成错误。检查每个OLE DB 状态值,如果可用。没有工作。"。
答案 0 :(得分:3)
该陈述相当于:
select listid, max(case when [order] = 1 then val end) as [1]
from gmt_listsvals
group by listid