;MERGE INTO Loanee p
USING ( SELECT * FROM @TApply AS nc) c on p.ApplicationID=c.ApplicationID
WHEN MATCHED THEN UPDATE set p.UpdateTime=getdate()
WHEN NOT MATCHED BY TARGET THEN INSERT
(
LoaneeNumber,LoaneeName,LoanDate,LockMatchRatio,SurplusMatchRatio,
MatchRatio,MatchAmount,LockAmount,LoaneeAmount,ExpectedYield,
LoanPeriod,CreditRating,FreeState,UpdateTime,AddTime,
DeleteState,IsFullState,FullTime,LoaneeType,ApplicationID,
CashAccountNo,ContractTime,RelaseRatio,MatchOrder,KsshDate,
LockState,CashAccountNo_Name,loaneeSource,Broker_CashAccount,Broker_CashAccountName,ApprovalTime)
VALUES(
c.LoaneeNumber,c.[LoaneeName],c.[LoanDate],0,1,
0,0,0,c.[LoaneeAmount],c.[ExpectedYield],
c.[LoanPeriod],c.[CreditRating],0,getdate(),getdate(),
0,0,null,0,c.[ApplicationID],
c.[CashAccountNo],c.[ContractTime],0,c.[MatchOrder],[KsshDate],
0,c.[CashAccountNo_Name],0,c.[Broker_CashAccount],c.[Broker_CashAccountName],c.ApprovalTime
);