sql批量操作系列

0.建表


 create table A 
(   
	  Id  int identity(1,1) not null, 
      Bid int not null, 
      Name varchar(20) null 
)

 insert into A (Bid,Name) values(1,'01')

 insert into A (Bid,Name) values(2,'02')

 insert into A (Bid,Name) values(3,'03')

create table B

( 
      Id  int identity(1,1) not null,

      Name varchar(20) null 
) 
insert into B(Name) values('good1')
insert into B(Name) values('good2')
insert into B(Name) values('good3')
select * from A
select * from B

1.批量更新操作 :

 

update A set Name=B.Name from B where A.Bid=B.Id

2.批量插入操作

insert into A 

select * from (
select Bid,Name  from A
) C

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章