我试图执行这个cte,但它说有一个语法错误,我找不到。
消息102,级别15,状态1,第21行“)”附近语法不正确。
谁能帮我找出一些我看不见的东西吗?
;with sqltmp (
eohdr_ouinstance, eohdr_eo_no, eohdr_rev_no,
eohdr_engdoctype, eohdr_src_doc_type, eohdr_mcm_no,
eoae_ac_reg_no, eoae_applicability_grp, eopse_part_no,
eopse_serial_no, eopse_component_id, maint_obj,
maint_obj_type, trans_status, pre_comp_date,
jobtype, exec_doc_no)
AS (
SELECT eohdr_ouinstance, eohdr_eo_no, eohdr_rev_no,
eohdr_engdoctype, eohdr_src_doc_type, eohdr_mcm_no,
eoae_ac_reg_no, eoae_applicability_grp, NULL,
NULL, NULL, eoae_ac_reg_no,
'A', eoae_applicable, eoae_precompdate,
'AC', eoae_precompdoc
FROM eo_eohdr_eo_header WITHa (NOLOCK)
JOIN eo_eoae_eo_ac_effect WITH (NOLOCK)
ON eohdr_ouinstance = eoae_ouinstance
AND eohdr_eo_no = eoae_eo_no
AND eohdr_rev_no = eoae_rev_no
AND eoae_applicable IN ('N', 'PCW')
AND ISNULL(eohdr_cr_no, '##') = '##'
UNION
SELECT eohdr_ouinstance, eohdr_eo_no, eohdr_rev_no,
eohdr_engdoctype, eohdr_src_doc_type, eohdr_mcm_no,
NULL, eopse_applicability_grp, eopse_part_no,
eopse_serial_no, eopse_component_id, eopse_component_id,
'C', eopse_applicable, eopse_precompdate,
CASE WHEN eohdr_instiu_flag = 'Y' THEN 'ON' ELSE 'OFWG' END,
eopse_precompdoc
FROM eo_eohdr_eo_header WITH (NOLOCK)
JOIN eo_eopse_eo_part_serial_effect WITH (NOLOCK)
ON eohdr_ouinstance = eopse_ouinstance
AND eohdr_eo_no = eopse_eo_no
AND eohdr_rev_no = eopse_rev_no
AND eopse_applicable IN ('N', 'PCW')
AND ISNULL(eohdr_cr_no,'##') = '##')
1条答案
按热度按时间ldxq2e6h1#
语法似乎很好。当您在cte定义之后添加select时,它的解析很好: