比较表之间的数据 [英] Compare the data between tables

查看:62
本文介绍了比较表之间的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的表数据如下所示

推荐答案

尝试:

merge #temp as target using #stg as srce on target.patientId = srce.patientId and target.patientVisitId = srce.PatientVisitId
when not matched then insert (patientId, PatientVisitId) values (srce.patientId, srce.PatientVisitId)
when not matched by source and target.patientId in (select s.patientId from #stg s)
then delete;

select * from #temp;


这篇关于比较表之间的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆