insert into a(ml,mc,nf) select ml,mc,'2010' from b
insert a(ml,mc,nf) select ml,mc,'2010' from b
insert into a(ml,mc,nf)select ml,mc,'2010' from b
-->sinpoal --->利用子查询将数据插入表中 insert into table1Select ml,mc,2010 from table2
if(object_id('A') > 0) drop table A go create table A( ml varchar(100),mc varchar(100),nf datetime ) insert into A select 'A','A','2009-10-01' union all select 'B','B','2010-1-1' union all select 'C','C','2010-1-2' if(object_id('B') > 0) drop table B go create table B( ml varchar(100),mc varchar(100) ) insert into B select ml,mc from A where datepart(yyyy,nf) = 2010 select * from B
insert into a(ml,mc,)select ml,mc from b 然后修改表a nf 列的默认值为2010
select ml,mc,'2010' from b
Select ml,mc,2010 from B
select ml,mc,'2010' from b
a(ml,mc,nf)
select
ml,mc,'2010'
from
b
select ml,mc,'2010' from b
insert into a(ml,mc,nf)select ml,mc,'2010' from b
-->sinpoal
--->利用子查询将数据插入表中
insert into table1Select ml,mc,2010
from table2
drop table A
go
create table A(
ml varchar(100),mc varchar(100),nf datetime
)
insert into A
select 'A','A','2009-10-01'
union all select 'B','B','2010-1-1'
union all select 'C','C','2010-1-2'
if(object_id('B') > 0)
drop table B
go
create table B(
ml varchar(100),mc varchar(100)
)
insert into B
select ml,mc from A where datepart(yyyy,nf) = 2010
select * from B
insert into a(ml,mc,)select ml,mc from b
然后修改表a nf 列的默认值为2010
select ml,mc,'2010' from b