菜鸟,问个问题=送分~~

ahao521 2007-11-22 01:28:20
怎么把2个库里的2个同一名字,结构也完全一样的表 合并起来?
如有相同的值就只留一个
...全文
140 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
ahao521 2007-11-22
  • 打赏
  • 举报
回复
insert UFDATA_725_2007..Inventory select * from UFDATA_114_2007..Inventory where not exists(select * from UFDATA_725_2007..Inventory)

UFDATA_725_2007和UFDATA_114_2007是2个库名Inventory是我要合并的表
但是出错了
“仅当使用了列的列表,并且 IDENTITY_INSERT 为 ON 时,才能在表 'UFDATA_725_2007..Inventory' 中为标识列指定显式值。”
中国风 2007-11-22
  • 打赏
  • 举报
回复
库A\B:
select * from A.dbo.A
union all
select * form B.dbo.A
-狙击手- 2007-11-22
  • 打赏
  • 举报
回复
a b 代表两个库
fa_ge 2007-11-22
  • 打赏
  • 举报
回复

select * from t1
union
select * from t2

-狙击手- 2007-11-22
  • 打赏
  • 举报
回复
insert a..table select * from b..table where not exists(select * from a..table)

34,590

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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