Format following T-SQL with using inner join syntax

use master
declare @channel as varchar(50) = ‘NOAH’
declare @agency_key as varchar(2) = ‘DL’
declare @run_date as datetime = cast(getdate() as date)

/* 1. delTxnRec /
delete from ingdatafeedu105…csw_brokerage_txn where Channel = @channel
and UpdateDateTime = @run_date

/ 2.1 saveTxnInData /
Insert Into ingdatafeedu105…csw_brokerage_txn
(Channel,UpdateDateTime,TransactionID,TransactionType,TransactionDate,Status)
select
@channel as Channel,
@run_date as UpdDate,
‘S’ + convert(CHAR(29), possm_trans_id) as [TransactionID],
(CASE WHEN possm_type = ‘0’ THEN ‘Booster’ WHEN possm_type = ‘1’ THEN ‘Transfer Booster’ WHEN possm_type = ‘2’ THEN ‘Switch In’ Else ‘’ END) as TransactionType,
CONVERT(char(10),possm_trans_datetime, 111) as [Transactiondate],
possm_status as Status
From ingposu105…Pos_SwitchIn_Main(nolock) s,
(select p.PolicyAccountID From ingciwu105…customer(nolock) cust, ingciwu105…csw_poli_rel(nolock)
poliRel, ingciwu105…PolicyAccount(nolock) p
Left Join ingciwu105…DataRetention_PII_Masked_Log(nolock) pii on p.PolicyAccountID = pii.PolicyNumber and pii.IsMasked =‘Y’
where cust.CustomerTypeCode = ‘AG’
and cust.AgentCode in (select camaid_agent_no from ingcamu105…cam_agent_info_dirmgr(nolock) where camaid_sort_key like ‘DL%’)
and poliRel.PolicyRelateCode IN (‘SA’)
and cust.CustomerID = poliRel.CustomerID
and poliRel.PolicyAccountID = p.PolicyAccountID
and p.CompanyID IN (‘ING’,‘EAA’,‘GL’)
and pii.PolicyNumber IS NULL
group by p.PolicyAccountID) p
Where s.possm_policy_no = p.PolicyAccountID
and (ISNULL(s.possm_tot_switchamt,0) <> 0 Or
ISNULL(s.possm_Transfer,0) <> 0 Or
ISNULL(s.possm_Booster,0) <>0 Or
ISNULL(s.possm_Coupon,0) <> 0 )
And s.possm_type IN (‘1’,‘2’)
And s.possm_eff_date <= @run_date


/ 2.2 saveTxnOutData */
Insert Into ingdatafeedu105…csw_brokerage_txn
(Channel,UpdateDateTime,TransactionID,TransactionType,TransactionDate,Status)
select
@channel as Channel,
@run_date as UpdDate,
‘P’ + convert(char(29),posph_trans_id) as [TransactionID] ,
(CASE WHEN posph_type = 0 THEN ‘Partial Surrender’
WHEN posph_type = 1 THEN ‘Switch out’
WHEN posph_type = 2 THEN ‘Reversal’
WHEN posph_type = 3 THEN ‘Cooling Off Fund Rider’
WHEN posph_type = 4 THEN ‘Surrender Fund Rider’ END) as [TransactionType],
CONVERT(char(10),posph_trans_datetime, 111) as [Transactiondate],
posph_status as Status
from ingposu105…pos_parsur_hist(nolock) s,
(select p.PolicyAccountID From ingciwu105…customer(nolock) cust, ingciwu105…Csw_poli_rel(nolock) poliRel, ingciwu105…PolicyAccount(nolock) p
Left Join ingciwu105…DataRetention_PII_Masked_Log(nolock) pii on p.PolicyAccountID = pii.PolicyNumber and pii.IsMasked =‘Y’
where cust.CustomerTypeCode = ‘AG’
and cust.AgentCode in (select camaid_agent_no from ingcamu105…cam_agent_info_dirmgr(nolock) where camaid_sort_key like ‘DL%’)
and poliRel.PolicyRelateCode IN (‘SA’)
and cust.CustomerID = poliRel.CustomerID
and poliRel.PolicyAccountID = p.PolicyAccountID
and p.CompanyID IN (‘ING’,‘EAA’,‘GL’)
and pii.PolicyNumber is null
group by p.PolicyAccountID) p
Where posph_policy_no = p.PolicyAccountID
And posph_eff_date <= @run_date
And posph_type IN (‘1’,‘2’,‘3’,‘4’,‘V’)

/*3. getTxnRec */
select Channel,CONVERT(VARCHAR(10),UpdateDateTime,111) as UpdateDateTime,TransactionID,TransactionType,
CONVERT(VARCHAR(10),TransactionDate,111) as TransactionDate,Status
from ingdatafeedu105…csw_brokerage_txn
where Channel = @channel
and UpdateDateTime = @run_date