MSSQL MERGE
-
MSSQL UPSERT 생성 :)DB/iBatis 2015. 1. 23. 14:48
고민의 고민을 하다가.. MERGE를 사용하기로 결정.. UPSERT를 만들어보기로 함. MERGE [테이블명] AS T USING (SELECT [받는 값(필드명과 매치)]) AS S ([필드명]) ON T.INDEX_SQ = S.INDEX_SQ WHEN MATCHED THEN [UPDATE 구문] WHEN NOT MATCHED THEN [INSERT구문] EX> MERGE MST_ADMIN_TD AS T USING (SELECT #{index_sq}, #{name_nm},'B', 'Y', getdate(), #{user_id}, #{user_pwd}, #{group_sq}) AS S (INDEX_SQ, NAME_NM, ADMIN_GB, USE_FL, REG_DT, USER_ID, USER_PWD, G..