用代码说话: create table #t (a1 int,a2 varchar(10))insert into #t select 1,'abc' union all select 2,'adsf' union all select 5,'ghsdaf' union all select 8,'hsh' --将表一复制到表二 select * into #t2 from #t--查看两表内容,完全一样 select * from #t select * from #t2drop table #t drop table #t2
select * into a from a$ 报错,数据库中已存在名为 'a' 的对象
insert into a select * from a$
1.table_new 原来已经存在且字段和顺序和table_old 完全一样,
insert into table_new select * from table_old 如不一样修改对应字段即可,注意插入数据主键问题.. insert into table_new(column1,column2) select column1,column2 from table_old 2.数据库中不存在table_new表 很简单 select * into table_new from table_old
select * into a from a$ 报错,数据库中已存在名为 'a' 的对象 -------------- 首先 drop table a 因为a已经存在,不能重建. 用insert 语法可以在已经存在表中增加记录,但是select into语法只能生成一个以前不存在的表
create table #t (a1 int,a2 varchar(10))insert into #t
select 1,'abc' union all
select 2,'adsf' union all
select 5,'ghsdaf' union all
select 8,'hsh' --将表一复制到表二
select * into #t2 from #t--查看两表内容,完全一样
select * from #t
select * from #t2drop table #t
drop table #t2
insert into table_new select * from table_old 如不一样修改对应字段即可,注意插入数据主键问题.. insert into table_new(column1,column2)
select column1,column2 from table_old 2.数据库中不存在table_new表 很简单 select * into table_new from table_old
--------------
首先 drop table a
因为a已经存在,不能重建.
用insert 语法可以在已经存在表中增加记录,但是select into语法只能生成一个以前不存在的表
有了就drop table a
然后再用 select * into a from a$