我有一个有趣的情况。我使用带有 SP1 的 SQL2014 企业版。以下查询会产生错误消息:
查询处理器耗尽了内部资源,无法生成查询计划。这是一种罕见的事件,仅适用于极其复杂的查询或引用大量表或分区的查询。请简化查询。如果您认为自己错误地收到了此消息,请联系客户支持服务以获取更多信息。
查询在没有插入语句的情况下运行良好。如果我交换 where 子句,查询也会运行,比如在exists 语句[step] = 1之后的exists 语句[step] = 3。实际上 SQL 是动态生成的,因此交换 where 子句中的顺序对我来说不是解决方案。这在 SQL 2008 和 SQL 2012 中运行良好。
推荐针对此问题的任何想法/解决方案,我感谢您的时间和精力。
insert into tblPatientConditions (
cmrn_id
,metricmnemonic
,metricname
,status
,adddate
)
select cmrn_id
,'PBLEHTN'
,'PossibleHTN'
,1
,Getdate()
from tblPatientInfo pers
where exists (
select *
from tblPatientDiagnosisCriteria
where cmrn_id = pers.cmrn_id
and metricname = 'PossibleHTN'
and category = 'CLAIMS'
and [step] = 1
and testname = 'HTN'
)
and exists ( …Run Code Online (Sandbox Code Playgroud)