正文

SQL批量更新某现存表某字段2008-08-11 19:34:00

【评论】 【打印】 【字体: 】 本文链接:http://blog.pfan.cn/yzrj/37496.html

分享到:

use Test

create table table1
(
   id int primary key identity(1,1),
   tValue nvarchar(15) not null
)

insert into table1 values('w322')

create table table2
(
  id int primary key identity(1,1),
  tva nvarchar(20) not null

)

insert into table2 values('55')

select * from table1
select * from table2

--更新
UPDATE table1
SET tValue=t2.tva
from table1
inner join  (select table2.id,table2.tva
     from table2) t2
on table1.id = t2.id

阅读(4100) | 评论(0)


版权声明:编程爱好者网站为此博客服务提供商,如本文牵涉到版权问题,编程爱好者网站不承担相关责任,如有版权问题请直接与本文作者联系解决。谢谢!

评论

暂无评论
您需要登录后才能评论,请 登录 或者 注册