2012-06-15 6 views
0

OLE DB 명령을 사용하여 기본 테이블 필드가 같은 테이블에 이미 존재하지 않을 때만 내 테이블에 행을 추가하려고합니다. 이것은 내가 지금까지 가지고있는 것입니다 :Sql 서버 SSIS 조건부 삽입

insert into employee 
    (employee_id, first_name, middle_initial, last_name) /*fields of the employee table*/ 
    values (employeedID, firstName, mInitial, lastName) /*columns from my input  */ 

/* only insert into the table where employee_ID is not already in the table */ 
where ((select employee_id from employee where employee_id = employeeID) = NULL); 

기본적으로 내가 원하는 것은 조건부 삽입 문입니다.

감사합니다.

+0

기존 행을 제거하기 위해 대상보다 먼저 조회 변환을 사용하지 않는 이유가 있습니까? – billinkc

답변

1

패키지가 어떻게 설정되어 있는지 정확히 알 수는 없지만 제약이없는 스테이징 테이블을 사용하는 것이 좋습니다. 모든 레코드를 먼저 넣은 다음 끝에 보이는 문장을 작성하십시오.

insert into employee (employee_id, first_name, middle_initial, last_name) 
select t.employee_id, t.first_name, t.middle_initial, t.last_name 
from temp_employee AS t 
left join employee ON t.employee_id = employee.employee_id 
where employee.employee_id is null