日期:2014-05-17 浏览次数:20493 次
--新建#a select * into #a from ( select 1 a ,'a' b union all select 2 ,'b' union all select 3 ,'c' union all select 4 ,'d' )a --新建#b select * into #b from ( select 5 a ,'a' b union all select 6 ,'b' union all select 7 ,'c' union all select 8 ,'d' )a --查询#a select * from #a --result: a b ----------- ---- 1 a 2 b 3 c 4 d (4 行受影响) --查询#b select * from #b --result: a b ----------- ---- 5 a 6 b 7 c 8 d (4 行受影响) --插入#a中a字段 insert into #a select a,'' b from #b (4 行受影响) --查询表#a select * from #a --result: a b ----------- ---- 5 6 7 8 1 a 2 b 3 c 4 d (8 行受影响)
------解决方案--------------------
insert b (column1) select column1 from a
------解决方案--------------------
INSERT INTO TB_A(COLUMN_NAME) SELECT COLUMN_NAME FROM TB_B