导入未存在的数据

wuzhongbaobupt 2008-12-01 01:40:55
从将A表的记录导入到B表(A表存在,B表未存在)
A与B的格式一样
COL1,COL2

只有COL1,COL2均一样的数据不导入到B表

这语句该怎样写,谢谢
...全文
56 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
hyde100 2008-12-01
  • 打赏
  • 举报
回复
--2005
insert into B(col1,col2)
select * from
(
select col1,col2 from A
except
select col1,col2 from B
)t
hyde100 2008-12-01
  • 打赏
  • 举报
回复
insert into B(col1,col2)
select col1,col2 from A
except
select col1,col2 from B
fcuandy 2008-12-01
  • 打赏
  • 举报
回复
insert b (col1,col2) select col1,col2 from a where not exists(select 1 from b where col1=a.col1 and col2=a.col2)

22,294

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 疑难问题
社区管理员
  • 疑难问题社区
  • 尘觉
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧