Friday, March 23, 2012

How can I optimize this routine

I need to update a very large fact summary table with the detail data from
other fact tables - what suggestions are there for making this perform bette
r
on the server?
UPDATE STAGE_PHX_FACT_POLICY
set county = FACT_POLICY_HO.County,Sub_County = FACT_POLICY_HO.Sub_County,
Zipcode = FACT_POLICY_HO.Zipcode,Policy_Form = FACT_POLICY_HO.Policy_Form,
Med_Pay_Amt = FACT_POLICY_HO.Med_Pay_Amt,Protection_Class =
FACT_POLICY_HO.Protection_Class,
Construction_Type = FACT_POLICY_HO.Construction_Type,Construction_Year =
FACT_POLICY_HO.Construction_Year,
Occupancy = FACT_POLICY_HO.Occupancy,RC_ACV_Bldg = FACT_POLICY_HO.RC_ACV_Bld
g,
RC_ACV_Contents = FACT_POLICY_HO.RC_ACV_Contents,Covg_Amount =
FACT_POLICY_HO.Amt_Of_Ins,
Ded_Amount = FACT_POLICY_HO.Ded_Amt,Liab_Amount = FACT_POLICY_HO.Liab_Amt
from FACT_POLICY_HO
where stage_phx_fact_policy.policy_number = fact_policy_ho.policy_number
and stage_phx_fact_policy.policy_date_time = fact_policy_ho.policy_date_time
UPDATE STAGE_PHX_FACT_POLICY
set Prot_Device = 'Y'
from fact_policy_ho
where smoke_detector = 'Y'
and stage_phx_fact_policy.policy_number = fact_policy_ho.policy_number
and stage_phx_fact_policy.policy_date_time = fact_policy_ho.policy_date_time
UPDATE STAGE_PHX_FACT_POLICY
set county = FACT_POLICY_MH.County,Zipcode = FACT_POLICY_MH.Zipcode,
Policy_Form = FACT_POLICY_MH.Policy_Form,Med_Pay_Amt =
FACT_POLICY_MH.Med_Pay_Amt,
Protection_Class = FACT_POLICY_MH.Protection_Class,Construction_Year =
FACT_POLICY_MH.Construction_Year,
Occupancy = FACT_POLICY_MH.Occupancy, RC_ACV_Bldg =
FACT_POLICY_MH.RC_ACV_Bldg,
RC_ACV_Contents = FACT_POLICY_MH.RC_ACV_Contents,Covg_Amount =
FACT_POLICY_MH.Amt_Of_Ins,
Ded_Amount = FACT_POLICY_MH.Ded_Amt,Liab_Amount = FACT_POLICY_MH.Liab_Amt
from FACT_POLICY_MH
where stage_phx_fact_policy.policy_number = fact_policy_mh.policy_number
and stage_phx_fact_policy.policy_date_time = fact_policy_mh.policy_date_time
UPDATE STAGE_PHX_FACT_POLICY
set Prot_Device = 'Y'
from fact_policy_mh
where smoke_detector = 'Y'
and stage_phx_fact_policy.policy_number = fact_policy_mh.policy_number
and stage_phx_fact_policy.policy_date_time = fact_policy_mh.policy_date_time
UPDATE STAGE_PHX_FACT_POLICY
set county = FACT_POLICY_LL.County,Sub_County = FACT_POLICY_LL.Sub_County,
Zipcode = FACT_POLICY_LL.Zipcode,Policy_Form = FACT_POLICY_LL.Policy_Form,
Protection_Class = FACT_POLICY_LL.Protection_Class,Construction_Type =
FACT_POLICY_LL.Construction_Type,
Construction_Year = FACT_POLICY_LL.Construction_Year,Occupancy =
FACT_POLICY_LL.Occupancy,
RC_ACV_Bldg = FACT_POLICY_LL.RC_ACV_Bldg,Covg_Amount =
FACT_POLICY_LL.Amt_Of_Ins,
Ded_Amount = FACT_POLICY_LL.Ded_Amt,Liab_Amount = FACT_POLICY_LL.Liab_Amt
from FACT_POLICY_LL
where stage_phx_fact_policy.policy_number = fact_policy_ll.policy_number
and stage_phx_fact_policy.policy_date_time = fact_policy_ll.policy_date_time
UPDATE STAGE_PHX_FACT_POLICY
set Prot_Device = 'Y'
from fact_policy_ll
where smoke_detector = 'Y'
and stage_phx_fact_policy.policy_number = fact_policy_ll.policy_number
and stage_phx_fact_policy.policy_date_time = fact_policy_ll.policy_date_time
UPDATE STAGE_PHX_FACT_POLICY
set county = FACT_POLICY_RF.County,Sub_County = FACT_POLICY_RF.Sub_County,
Zipcode = FACT_POLICY_RF.Zipcode,Policy_Form = FACT_POLICY_RF.Policy_Form,
Protection_Class = FACT_POLICY_RF.Protection_Class,Construction_Type =
FACT_POLICY_RF.Construction_Type,
Construction_Year = FACT_POLICY_RF.Construction_Year,Occupancy =
FACT_POLICY_RF.Occupancy,
RC_ACV_Bldg = FACT_POLICY_RF.RC_ACV_Bldg,RC_ACV_Contents =
FACT_POLICY_RF.RC_ACV_Contents,
Primary_Loc = FACT_POLICY_RF.Primary_Loc,Covg_Amount =
FACT_POLICY_RF.Amt_Of_Ins,
Ded_Amount = FACT_POLICY_RF.Ded_Amt,Liab_Amount = FACT_POLICY_RF.Liab_Amt
from FACT_POLICY_RF
where stage_phx_fact_policy.policy_number = fact_policy_rf.policy_number
and stage_phx_fact_policy.policy_date_time = fact_policy_rf.policy_date_time
UPDATE STAGE_PHX_FACT_POLICY
set county = FACT_POLICY_CF.County,Sub_County = FACT_POLICY_CF.Sub_County,
Zipcode = FACT_POLICY_CF.Zipcode,Policy_Form = FACT_POLICY_CF.Policy_Form,
Protection_Class = FACT_POLICY_CF.Protection_Class,Construction_Type =
FACT_POLICY_CF.Construction_Type,
Occupancy = FACT_POLICY_CF.Owner_Occupied,RC_ACV_Bldg =
FACT_POLICY_CF.RC_ACV_Bldg,
RC_ACV_Contents = FACT_POLICY_CF.RC_ACV_Contents,Primary_Loc =
FACT_POLICY_CF.Primary_Loc,
Covg_Amount = FACT_POLICY_CF.Amt_Of_Ins,Ded_Amount = FACT_POLICY_CF.Ded_Amt,
Liab_Amount = FACT_POLICY_CF.Liab_Amt
from FACT_POLICY_CF
where stage_phx_fact_policy.policy_number = fact_policy_cf.policy_number
and stage_phx_fact_policy.policy_date_time = fact_policy_cf.policy_date_time
UPDATE STAGE_PHX_FACT_POLICY
set Prot_Device = 'Y'
from fact_policy_cf
where fire_burglary_system = 'Y'
and stage_phx_fact_policy.policy_number = fact_policy_cf.policy_number
and stage_phx_fact_policy.policy_date_time = fact_policy_cf.policy_date_time
UPDATE STAGE_PHX_FACT_POLICY
set county = FACT_POLICY_SMP.County,Sub_County = FACT_POLICY_SMP.Sub_County,
Zipcode = FACT_POLICY_SMP.Zipcode,Policy_Form = FACT_POLICY_SMP.Policy_Form,
Protection_Class = FACT_POLICY_SMP.Protection_Class,Construction_Type =
FACT_POLICY_SMP.Construction_Type,
Occupancy = FACT_POLICY_SMP.Owner_Occupied,RC_ACV_Bldg =
FACT_POLICY_SMP.RC_ACV_Bldg,
RC_ACV_Contents = FACT_POLICY_SMP.RC_ACV_Contents,Primary_Loc =
FACT_POLICY_SMP.Primary_Loc,
Covg_Amount = FACT_POLICY_SMP.Amt_Of_Ins,Ded_Amount = FACT_POLICY_SMP.Ded_Am
t,
Liab_Amount = FACT_POLICY_SMP.Liab_Amt
from FACT_POLICY_SMP
where stage_phx_fact_policy.policy_number = fact_policy_smp.policy_number
and stage_phx_fact_policy.policy_date_time = fact_policy_smp.policy_date_tim
e
UPDATE STAGE_PHX_FACT_POLICY
set Prot_Device = 'Y'
from fact_policy_smp
where fire_burglary_system = 'Y'
and stage_phx_fact_policy.policy_number = fact_policy_smp.policy_number
and stage_phx_fact_policy.policy_date_time = fact_policy_smp.policy_date_tim
e
UPDATE STAGE_PHX_FACT_POLICY
set county = FACT_POLICY_BOP.County,Sub_County = FACT_POLICY_BOP.Sub_County,
Zipcode = FACT_POLICY_BOP.Zipcode,Policy_Form = FACT_POLICY_BOP.Policy_Form,
Protection_Class = FACT_POLICY_BOP.Protection_Class,Construction_Type =
FACT_POLICY_BOP.Construction_Type,
Occupancy = FACT_POLICY_BOP.Occupancy,RC_ACV_Bldg =
FACT_POLICY_BOP.RC_ACV_Bldg,
RC_ACV_Contents = FACT_POLICY_BOP.RC_ACV_Contents,Primary_Loc =
FACT_POLICY_BOP.Primary_Loc,
Covg_Amount = FACT_POLICY_BOP.Amt_Of_Ins,Ded_Amount = FACT_POLICY_BOP.Ded_Am
t,
Liab_Amount = FACT_POLICY_BOP.Liab_Amt
from FACT_POLICY_BOP
where stage_phx_fact_policy.policy_number = fact_policy_bop.policy_number
and stage_phx_fact_policy.policy_date_time = fact_policy_bop.policy_date_tim
e
UPDATE STAGE_PHX_FACT_POLICY
set county = FACT_POLICY_FO.County,Sub_County = FACT_POLICY_FO.Sub_County,
Zipcode = FACT_POLICY_FO.Zipcode,Policy_Form = FACT_POLICY_FO.Policy_Form,
Med_Pay_Amt = FACT_POLICY_FO.Med_Pay_Amt,Protection_Class =
FACT_POLICY_FO.Protection_Class,
Construction_Type = FACT_POLICY_FO.Construction_Type,Occupancy =
FACT_POLICY_FO.Occupancy,
RC_ACV_Bldg = FACT_POLICY_FO.RC_ACV_Bldg,RC_ACV_Contents =
FACT_POLICY_FO.RC_ACV_Contents,
Primary_Loc = FACT_POLICY_FO.Primary_Loc,Covg_Amount =
FACT_POLICY_FO.Amt_Of_Ins,
Ded_Amount = FACT_POLICY_FO.Ded_Amt,Liab_Amount = FACT_POLICY_FO.Liab_Amt
from FACT_POLICY_FO
where stage_phx_fact_policy.policy_number = fact_policy_fo.policy_number
and stage_phx_fact_policy.policy_date_time = fact_policy_fo.policy_date_time
UPDATE STAGE_PHX_FACT_POLICY
set Prot_Device = 'Y'
from fact_policy_fo
where smoke_detector = 'Y'
and stage_phx_fact_policy.policy_number = fact_policy_fo.policy_number
and stage_phx_fact_policy.policy_date_time = fact_policy_fo.policy_date_time
UPDATE STAGE_PHX_FACT_POLICY
set county = FACT_POLICY_AP.County,Sub_County = FACT_POLICY_AP.Sub_County,
Zipcode = FACT_POLICY_AP.Zipcode,Policy_Form = FACT_POLICY_AP.Policy_Form,
Med_Pay_Amt = FACT_POLICY_AP.Med_Pay_Amt,Protection_Class =
FACT_POLICY_AP.Protection_Class,
Construction_Type = FACT_POLICY_AP.Construction_Type,Occupancy =
FACT_POLICY_AP.Occupancy,
RC_ACV_Bldg = FACT_POLICY_AP.RC_ACV_Bldg,RC_ACV_Contents =
FACT_POLICY_AP.RC_ACV_Contents,
Primary_Loc = FACT_POLICY_AP.Primary_Loc,Covg_Amount =
FACT_POLICY_AP.Amt_Of_Ins,
Ded_Amount = FACT_POLICY_AP.Ded_Amt,Liab_Amount = FACT_POLICY_AP.Liab_Amt
from FACT_POLICY_AP
where stage_phx_fact_policy.policy_number = fact_policy_ap.policy_number
and stage_phx_fact_policy.policy_date_time = fact_policy_ap.policy_date_time
Would a UNION work better?
Thanks!Hi Patrice
It is not clear if the information in FACT_POLICY_HO and FACT_POLICY_HM are
exclusive, if that is the case then they could be unioned in a subquery. If
not you might be able to use an outer join and check that they exist in
FACT_POLICY_HM before assigning the value in FACT_POLICY_HO.
For the first two statements they can be consolidated as:
UPDATE s
set county = f.County,
Sub_County = f.Sub_County,
Zipcode = f.Zipcode,
Policy_Form = f.Policy_Form,
Med_Pay_Amt = f.Med_Pay_Amt,
Protection_Class = f.Protection_Class,
Construction_Type = f.Construction_Type,
Construction_Year = f.Construction_Year,
Occupancy = f.Occupancy,
RC_ACV_Bldg = f.RC_ACV_Bldg,
RC_ACV_Contents = f.RC_ACV_Contents,
Covg_Amount = f.Amt_Of_Ins,
Ded_Amount = f.Ded_Amt,
Liab_Amount = f.Liab_Amt,
Prot_Device = CASE WHEN s.smoke_detector = 'Y' THEN 'Y' ELSE Prot_Device END
set county = m.County,
from STAGE_PHX_FACT_POLICY s
JOIN FACT_POLICY_HO f ON s.policy_number = f.policy_number and
s.policy_date_time = f.policy_date_time
You can then extend this to cater for the FACT_POLICY_HM table.
John
"Patrice" wrote:

> I need to update a very large fact summary table with the detail data from
> other fact tables - what suggestions are there for making this perform bet
ter
> on the server?
>
> UPDATE STAGE_PHX_FACT_POLICY
> set county = FACT_POLICY_HO.County,Sub_County = FACT_POLICY_HO.Sub_County,
> Zipcode = FACT_POLICY_HO.Zipcode,Policy_Form = FACT_POLICY_HO.Policy_Form,
> Med_Pay_Amt = FACT_POLICY_HO.Med_Pay_Amt,Protection_Class =
> FACT_POLICY_HO.Protection_Class,
> Construction_Type = FACT_POLICY_HO.Construction_Type,Construction_Year =
> FACT_POLICY_HO.Construction_Year,
> Occupancy = FACT_POLICY_HO.Occupancy,RC_ACV_Bldg = FACT_POLICY_HO.RC_ACV_B
ldg,
> RC_ACV_Contents = FACT_POLICY_HO.RC_ACV_Contents,Covg_Amount =
> FACT_POLICY_HO.Amt_Of_Ins,
> Ded_Amount = FACT_POLICY_HO.Ded_Amt,Liab_Amount = FACT_POLICY_HO.Liab_Amt
> from FACT_POLICY_HO
> where stage_phx_fact_policy.policy_number = fact_policy_ho.policy_number
> and stage_phx_fact_policy.policy_date_time = fact_policy_ho.policy_date_ti
me
> UPDATE STAGE_PHX_FACT_POLICY
> set Prot_Device = 'Y'
> from fact_policy_ho
> where smoke_detector = 'Y'
> and stage_phx_fact_policy.policy_number = fact_policy_ho.policy_number
> and stage_phx_fact_policy.policy_date_time = fact_policy_ho.policy_date_ti
me
>
> UPDATE STAGE_PHX_FACT_POLICY
> set county = FACT_POLICY_MH.County,Zipcode = FACT_POLICY_MH.Zipcode,
> Policy_Form = FACT_POLICY_MH.Policy_Form,Med_Pay_Amt =
> FACT_POLICY_MH.Med_Pay_Amt,
> Protection_Class = FACT_POLICY_MH.Protection_Class,Construction_Year =
> FACT_POLICY_MH.Construction_Year,
> Occupancy = FACT_POLICY_MH.Occupancy, RC_ACV_Bldg =
> FACT_POLICY_MH.RC_ACV_Bldg,
> RC_ACV_Contents = FACT_POLICY_MH.RC_ACV_Contents,Covg_Amount =
> FACT_POLICY_MH.Amt_Of_Ins,
> Ded_Amount = FACT_POLICY_MH.Ded_Amt,Liab_Amount = FACT_POLICY_MH.Liab_Amt
> from FACT_POLICY_MH
> where stage_phx_fact_policy.policy_number = fact_policy_mh.policy_number
> and stage_phx_fact_policy.policy_date_time = fact_policy_mh.policy_date_ti
me
>
> UPDATE STAGE_PHX_FACT_POLICY
> set Prot_Device = 'Y'
> from fact_policy_mh
> where smoke_detector = 'Y'
> and stage_phx_fact_policy.policy_number = fact_policy_mh.policy_number
> and stage_phx_fact_policy.policy_date_time = fact_policy_mh.policy_date_ti
me
>
>
> UPDATE STAGE_PHX_FACT_POLICY
> set county = FACT_POLICY_LL.County,Sub_County = FACT_POLICY_LL.Sub_County,
> Zipcode = FACT_POLICY_LL.Zipcode,Policy_Form = FACT_POLICY_LL.Policy_Form,
> Protection_Class = FACT_POLICY_LL.Protection_Class,Construction_Type =
> FACT_POLICY_LL.Construction_Type,
> Construction_Year = FACT_POLICY_LL.Construction_Year,Occupancy =
> FACT_POLICY_LL.Occupancy,
> RC_ACV_Bldg = FACT_POLICY_LL.RC_ACV_Bldg,Covg_Amount =
> FACT_POLICY_LL.Amt_Of_Ins,
> Ded_Amount = FACT_POLICY_LL.Ded_Amt,Liab_Amount = FACT_POLICY_LL.Liab_Amt
> from FACT_POLICY_LL
> where stage_phx_fact_policy.policy_number = fact_policy_ll.policy_number
> and stage_phx_fact_policy.policy_date_time = fact_policy_ll.policy_date_ti
me
> UPDATE STAGE_PHX_FACT_POLICY
> set Prot_Device = 'Y'
> from fact_policy_ll
> where smoke_detector = 'Y'
> and stage_phx_fact_policy.policy_number = fact_policy_ll.policy_number
> and stage_phx_fact_policy.policy_date_time = fact_policy_ll.policy_date_ti
me
>
>
> UPDATE STAGE_PHX_FACT_POLICY
> set county = FACT_POLICY_RF.County,Sub_County = FACT_POLICY_RF.Sub_County,
> Zipcode = FACT_POLICY_RF.Zipcode,Policy_Form = FACT_POLICY_RF.Policy_Form,
> Protection_Class = FACT_POLICY_RF.Protection_Class,Construction_Type =
> FACT_POLICY_RF.Construction_Type,
> Construction_Year = FACT_POLICY_RF.Construction_Year,Occupancy =
> FACT_POLICY_RF.Occupancy,
> RC_ACV_Bldg = FACT_POLICY_RF.RC_ACV_Bldg,RC_ACV_Contents =
> FACT_POLICY_RF.RC_ACV_Contents,
> Primary_Loc = FACT_POLICY_RF.Primary_Loc,Covg_Amount =
> FACT_POLICY_RF.Amt_Of_Ins,
> Ded_Amount = FACT_POLICY_RF.Ded_Amt,Liab_Amount = FACT_POLICY_RF.Liab_Amt
> from FACT_POLICY_RF
> where stage_phx_fact_policy.policy_number = fact_policy_rf.policy_number
> and stage_phx_fact_policy.policy_date_time = fact_policy_rf.policy_date_ti
me
>
>
> UPDATE STAGE_PHX_FACT_POLICY
> set county = FACT_POLICY_CF.County,Sub_County = FACT_POLICY_CF.Sub_County,
> Zipcode = FACT_POLICY_CF.Zipcode,Policy_Form = FACT_POLICY_CF.Policy_Form,
> Protection_Class = FACT_POLICY_CF.Protection_Class,Construction_Type =
> FACT_POLICY_CF.Construction_Type,
> Occupancy = FACT_POLICY_CF.Owner_Occupied,RC_ACV_Bldg =
> FACT_POLICY_CF.RC_ACV_Bldg,
> RC_ACV_Contents = FACT_POLICY_CF.RC_ACV_Contents,Primary_Loc =
> FACT_POLICY_CF.Primary_Loc,
> Covg_Amount = FACT_POLICY_CF.Amt_Of_Ins,Ded_Amount = FACT_POLICY_CF.Ded_Am
t,
> Liab_Amount = FACT_POLICY_CF.Liab_Amt
> from FACT_POLICY_CF
> where stage_phx_fact_policy.policy_number = fact_policy_cf.policy_number
> and stage_phx_fact_policy.policy_date_time = fact_policy_cf.policy_date_ti
me
>
> UPDATE STAGE_PHX_FACT_POLICY
> set Prot_Device = 'Y'
> from fact_policy_cf
> where fire_burglary_system = 'Y'
> and stage_phx_fact_policy.policy_number = fact_policy_cf.policy_number
> and stage_phx_fact_policy.policy_date_time = fact_policy_cf.policy_date_ti
me
>
>
> UPDATE STAGE_PHX_FACT_POLICY
> set county = FACT_POLICY_SMP.County,Sub_County = FACT_POLICY_SMP.Sub_Count
y,
> Zipcode = FACT_POLICY_SMP.Zipcode,Policy_Form = FACT_POLICY_SMP.Policy_For
m,
> Protection_Class = FACT_POLICY_SMP.Protection_Class,Construction_Type =
> FACT_POLICY_SMP.Construction_Type,
> Occupancy = FACT_POLICY_SMP.Owner_Occupied,RC_ACV_Bldg =
> FACT_POLICY_SMP.RC_ACV_Bldg,
> RC_ACV_Contents = FACT_POLICY_SMP.RC_ACV_Contents,Primary_Loc =
> FACT_POLICY_SMP.Primary_Loc,
> Covg_Amount = FACT_POLICY_SMP.Amt_Of_Ins,Ded_Amount = FACT_POLICY_SMP.Ded_
Amt,
> Liab_Amount = FACT_POLICY_SMP.Liab_Amt
> from FACT_POLICY_SMP
> where stage_phx_fact_policy.policy_number = fact_policy_smp.policy_number
> and stage_phx_fact_policy.policy_date_time = fact_policy_smp.policy_date_t
ime
> UPDATE STAGE_PHX_FACT_POLICY
> set Prot_Device = 'Y'
> from fact_policy_smp
> where fire_burglary_system = 'Y'
> and stage_phx_fact_policy.policy_number = fact_policy_smp.policy_number
> and stage_phx_fact_policy.policy_date_time = fact_policy_smp.policy_date_t
ime
>
> UPDATE STAGE_PHX_FACT_POLICY
> set county = FACT_POLICY_BOP.County,Sub_County = FACT_POLICY_BOP.Sub_Count
y,
> Zipcode = FACT_POLICY_BOP.Zipcode,Policy_Form = FACT_POLICY_BOP.Policy_For
m,
> Protection_Class = FACT_POLICY_BOP.Protection_Class,Construction_Type =
> FACT_POLICY_BOP.Construction_Type,
> Occupancy = FACT_POLICY_BOP.Occupancy,RC_ACV_Bldg =
> FACT_POLICY_BOP.RC_ACV_Bldg,
> RC_ACV_Contents = FACT_POLICY_BOP.RC_ACV_Contents,Primary_Loc =
> FACT_POLICY_BOP.Primary_Loc,
> Covg_Amount = FACT_POLICY_BOP.Amt_Of_Ins,Ded_Amount = FACT_POLICY_BOP.Ded_
Amt,
> Liab_Amount = FACT_POLICY_BOP.Liab_Amt
> from FACT_POLICY_BOP
> where stage_phx_fact_policy.policy_number = fact_policy_bop.policy_number
> and stage_phx_fact_policy.policy_date_time = fact_policy_bop.policy_date_t
ime
>
>
> UPDATE STAGE_PHX_FACT_POLICY
> set county = FACT_POLICY_FO.County,Sub_County = FACT_POLICY_FO.Sub_County,
> Zipcode = FACT_POLICY_FO.Zipcode,Policy_Form = FACT_POLICY_FO.Policy_Form,
> Med_Pay_Amt = FACT_POLICY_FO.Med_Pay_Amt,Protection_Class =
> FACT_POLICY_FO.Protection_Class,
> Construction_Type = FACT_POLICY_FO.Construction_Type,Occupancy =
> FACT_POLICY_FO.Occupancy,
> RC_ACV_Bldg = FACT_POLICY_FO.RC_ACV_Bldg,RC_ACV_Contents =
> FACT_POLICY_FO.RC_ACV_Contents,
> Primary_Loc = FACT_POLICY_FO.Primary_Loc,Covg_Amount =
> FACT_POLICY_FO.Amt_Of_Ins,
> Ded_Amount = FACT_POLICY_FO.Ded_Amt,Liab_Amount = FACT_POLICY_FO.Liab_Amt
> from FACT_POLICY_FO
> where stage_phx_fact_policy.policy_number = fact_policy_fo.policy_number
> and stage_phx_fact_policy.policy_date_time = fact_policy_fo.policy_date_ti
me
> UPDATE STAGE_PHX_FACT_POLICY
> set Prot_Device = 'Y'
> from fact_policy_fo
> where smoke_detector = 'Y'
> and stage_phx_fact_policy.policy_number = fact_policy_fo.policy_number
> and stage_phx_fact_policy.policy_date_time = fact_policy_fo.policy_date_ti
me
>
>
> UPDATE STAGE_PHX_FACT_POLICY
> set county = FACT_POLICY_AP.County,Sub_County = FACT_POLICY_AP.Sub_County,
> Zipcode = FACT_POLICY_AP.Zipcode,Policy_Form = FACT_POLICY_AP.Policy_Form,
> Med_Pay_Amt = FACT_POLICY_AP.Med_Pay_Amt,Protection_Class =
> FACT_POLICY_AP.Protection_Class,
> Construction_Type = FACT_POLICY_AP.Construction_Type,Occupancy =
> FACT_POLICY_AP.Occupancy,
> RC_ACV_Bldg = FACT_POLICY_AP.RC_ACV_Bldg,RC_ACV_Contents =
> FACT_POLICY_AP.RC_ACV_Contents,
> Primary_Loc = FACT_POLICY_AP.Primary_Loc,Covg_Amount =
> FACT_POLICY_AP.Amt_Of_Ins,
> Ded_Amount = FACT_POLICY_AP.Ded_Amt,Liab_Amount = FACT_POLICY_AP.Liab_Amt
> from FACT_POLICY_AP
> where stage_phx_fact_policy.policy_number = fact_policy_ap.policy_number
> and stage_phx_fact_policy.policy_date_time = fact_policy_ap.policy_date_ti
me
>
> Would a UNION work better?
> Thanks!
>sql

No comments:

Post a Comment