2008/05/16 | 用A表数据更新B表数据的示例
类别(数据库学习笔记) | 评论(0) | 阅读(155) | 发表于 17:00


create table at(id int ,cap char(10) default(''))
create table bt(id int ,cap char(10))


declare @i int

set @i=1
while @i<100
begin
  insert into at values(@i,default)
  set @i= @i+1
end


set @i=1
while @i<100
begin
  insert into bt values(@i,'aa'+cast(@i as char(4)) )
  set @i= @i+1
end

 

update at set at.cap =bt.cap from at,bt where at.id=bt.id

select * from at
select * from bt

0

评论Comments