[MS-SQL] EXISTS , ISNULL함수 사용법
MSSQL의 EXISTS , ISNULL 함수 사용법
< update id=”UpdateTestTable” parameterClass=”TestParameter” >
IF NOT EXISTS (SELECT * FROM Test_Table WHERE PK_ID = #PID#)
BEGIN
Insert Test_Table(PK_ID, IsUseWeb, LastUpdateUserID, LastUpdateDateTime)
VALUES(#PID#, #IsUseWeb#, #LoginUserID#, GETDATE())
END
ELSE
BEGIN
UPDATE Test_Table
SET IsUseWeb = #IsUseWeb#
< isNotEmpty prepend=”” property=”UserID” >
,LastUpdateUserID = #UserID#
< /isNotEmpty>
,LastUpdateDateTime = GETDATE()
WHERE PK_ID = #PID#
END
IF ISNULL(#IsUseWeb#,”) != ” and ISNULL(#UserID#,”) != ”
BEGIN
Insert Test_Table(PK_ID, IsUseWeb, LastUpdateUserID, LastUpdateDateTime)
VALUES(#PID#, #IsUseWeb#, #LoginUserID#, GETDATE())
END
< /update>