iT邦幫忙

3

[MS SQL] 找出2張表的差異

  • 分享至 

  • twitterImage
  •  

show2個table的差異處
在這裡做2個table,
然後有一row相異


select * into #tmp1 from 
(
select co1=1,col2=2,col3=3 
union
select co1=1,col2=2,col3=4 
union
select co1=1,col2=2,col3=5
)t0

select * into #tmp2 from 
(
select co1=1,col2=2,col3=3 
union
select co1=1,col2=2,col3=4 
union
select co1=1,col2=2,col3=6
)t0

--show diff 
select 'tmp2沒有',* from (
--show tmp1有,tmp2沒有
SELECT  * from #tmp1
EXCEPT	--在ORACLE的話,用MINUS
SELECT  * FROM #tmp2) t0
union
select 'tmp1沒有',* from 
(
--show tmp2有,tmp1沒有
SELECT  * from #tmp2
EXCEPT	--在ORACLE的話,用MINUS
SELECT * FROM #tmp1) t1

ref
https://dotblogs.com.tw/rainmaker/2010/12/06/19940


圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言