兩個數據庫表中合併數據

--忽略表之間的關聯關係
ALTER TABLE db2.dbo.table NOCHECK CONSTRAINT 關係名

--將沒有重複的數據合併
insert into db2.dbo.table(field1,field2...) select field1,field2... from db1.dbo.table a where a.username not in (select username from db2.dbo.table)

--將重複的數據寫入臨時表
select field1,field2... into 新的臨時表 from db1.dbo.table a where a.username in (select username from db2.dbo.table) 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章