此查询有效
select c.claimid, c.member, c.authno, c.claim_type, c.provider, c.vendor,
c.claimdeny, c.date_approved, c.date_received, c.lob
from xxx.xxx.dbo.clm c
where c.claimid in (
select **top 12** d.DENIAL_CLAIM_ID
from DN_APPEAL_REQUEST d
where d.DENIAL_TYPE='C' order by APPEAL_ID
)
此查询不起作用
select c.claimid, c.member, c.authno, c.claim_type, c.provider, c.vendor,
c.claimdeny, c.date_approved, c.date_received, c.lob
from xxx.xxx.dbo.clm c
where c.claimid in (
select **top 13** d.DENIAL_CLAIM_ID
from DN_APPEAL_REQUEST d
where d.DENIAL_TYPE='C' order by APPEAL_ID
)
xxx.xxx是链接服务器
第二个查询运行一段时间然后失败,并显示一条错误消息,指出先前的sql语句格式错误。
第一个子查询的结果
913900133
916303197
833701140
028100832
028100832
028100832
835900898
205407041
214402039
112504239
213601714
314700730
第二个子查询的结果
913900133
916303197
833701140
028100832
028100832
028100832
835900898
205407041
214402039
112504239
213601714
314700730
214301493
dn_appeal_request只有18条记录。我试图分别在链接服务器表上为每个claimid运行查询。它没有问题。