这样的存储过程应该怎么写?

FlyingQQ 2003-11-24 02:00:23
我有表A和表B
A:
ID VALUE TYPE
B:
ID A_ID VALUE TYPE
A为B的索引表,客户要求,根据不同的用户要求,能修改索引的数据,新的索引数据从B中得到,而旧的索引数据替换B中的原有数据,可是我不知道该如何写才能把A表的数据和B中的数据进行交换,哪位大侠帮忙写写~!
...全文
77 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
LoveSQL 2003-11-24
  • 打赏
  • 举报
回复
Select * into #tmp from A
update A set a.value = b.value,a.type = b.type from A ,b where a.id = b.a_id
update B set b.value = a.value,b.type = a.type from #tmp a , b where a.id = b.a_id
zjcxc 元老 2003-11-24
  • 打赏
  • 举报
回复
update b set value=a.value from a where a.id=b.a_id
pengdali 2003-11-24
  • 打赏
  • 举报
回复
update b set value=a.value from a where a.id=b.a_id
txlicenhe 2003-11-24
  • 打赏
  • 举报
回复
Select * into #tmp from A
update A set a.value = b.value,a.type = b.type from A join b on a.id = b.a_id
update B set b.value = a.value,b.type = a.type from #tmp a join b on a.id = b.a_id

34,576

社区成员

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

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