用A表数据更新B表数据的示例

      数据库学习笔记 2008-5-16 17:0


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

标签集:TAGS:示例
回复Comments() 点击Count()

回复Comments

{commentauthor}
{commentauthor}
{commenttime}
{commentnum}
{commentcontent}
作者:
{commentrecontent}