Hi,
I am trying to simplify the 2 queries below into one query but I'm running out of idea...
Anyone could help is really appreciated
I am trying to simplify the 2 queries below into one query but I'm running out of idea...
Code:
INSERT INTO SYST_DETL
(
[SYST_DETL_I]
,[SYST_DETL_TABL_I]
,[PL_1_I]
)
SELECT
@Syst_DETL_I
,(SELECT SYST_DETL_TABL_I FROM SYST_DETL_TABL WHERE TABL_NAME_M = 'EMPLOYEE') AS SYST_DETL_TABL_I
,f.GEMS_EMPLOYEE_I
FROM LOAD..CREDIT_EMPLOYEE_FPX crc
INNER JOIN EMPLOYEE f ON crc.EMPLOYEE_BRCH_ACCT_N = f.EMPLOYEE_BRCH_ACCT_N
WHERE ( f.GEMS_CLNT_I != @AggrClientID AND crc.GEMS_EMPLOYEE_I IS NOT NULL) OR ( crc.GEMS_EMPLOYEE_I IS NULL)
INSERT INTO SYST_DETL
(
[SYST_DETL_I]
,[SYST_DETL_TABL_I]
,[PL_1_I]
,[PL_2_I]
,[PL_3_I]
)
SELECT
@Syst_DETL_I
,(SELECT SYST_DETL_TABL_I FROM SYST_DETL_TABL WHERE TABL_NAME_M = 'EMPLOYEE_PX') AS SYST_DETL_TABL_I
,f.GEMS_EMPLOYEE_I
,CONVERT(VARCHAR(50),@Exposure_Date,121)
,@Currency_Code
FROM LOAD..CREDIT_EMPLOYEE_FPX crc
INNER JOIN EMPLOYEE f ON crc.EMPLOYEE_BRCH_ACCT_N = f.EMPLOYEE_BRCH_ACCT_N
Anyone could help is really appreciated