Databases
특정 컬럼 테이블 복사 (insert,update)
duraboys
2011. 7. 12. 12:03
적용 방법
insert into 변경될 테이블 (컬럼1,컬럼2,컬럼3...) select 원본컬럼1, 원본컬럼2, 원본컬럼3... from 원본테이블
select *
into #Ta
from (
select 0 필드 , '가' 필드 , '' 필드 union all
select 2 , '장' , ''union all
select 4 , '해' , ''union all
select 6 , '별' , '') r
drop table #Tb
select *
into #Tb
from (
select 0 필드 , 'A' 필드 union all
select 1 , 'B' union all
select 2 , 'C' union all
select 3 , 'D' union all
select 4 , 'E' union all
select 5 , 'F' union all
select 6 , 'F' union all
select 6 , 'G' union all
select 6 , 'P' ) r
select * from #ta
select *
from #ta a inner join #tb b on a.필드 =b.필드
update #ta
set 필드= b.필드
from #ta a inner join #tb b on a.필드 =b.필드
select * from #ta
update #ta
set 필드= b.필드
from #ta a inner join #tb b on a.필드 =b.필드