UPDATE:UPDATE A SET ApproverID=NULL FROM [SH_MaterialApplyBuyBill] A LEFT JOIN [SH_MaterialApplyBuyBillDetail] B ON A.ID=B.[MaterialApplyBuyBillID]WHERE A.id=125 AND @InDetailCount=0DELETE:DELETE A FROM [SH_ClosingBalance] A LEFT JOIN [SH_StoreHouse]…