update / refresh query

P

phillip9

Hello,

I need some help with this problem please.

BACKGROUND
I need to update a local copy of a national database once a day. I link to
the national database through ODBC drivers. I created an update query which
works great as long as the information is already in the local copy, but if
new information for my region is put into the national database, I do not get
the new information updated into my local copy.

DETAIL
national database
all states of the U.S.A
local database
just MICHIGAN U.S.A.

SQL QUERY

UPDATE DISTINCTROW dbo_active_property INNER JOIN mi_active_property ON
dbo_active_property.property_id = mi_active_property.property_id SET
mi_active_property.hub_name_text = [dbo_active_property].[hub_name_text],
mi_active_property.servicing_site_name_text =
[dbo_active_property].[servicing_site_name_text],
mi_active_property.project_manager_name_text =
[dbo_active_property].[project_manager_name_text],
mi_active_property.property_id = [dbo_active_property].[property_id],
mi_active_property.property_name_text =
[dbo_active_property].[property_name_text],
mi_active_property.address_line1_text =
[dbo_active_property].[address_line1_text],
mi_active_property.address_line2_text =
[dbo_active_property].[address_line2_text], mi_active_property.city_name_text
= [dbo_active_property].[city_name_text], mi_active_property.state_code =
[dbo_active_property].[state_code], mi_active_property.state_name_text =
[dbo_active_property].[state_name_text], mi_active_property.zip_code =
[dbo_active_property].[zip_code], mi_active_property.zip4_code =
[dbo_active_property].[zip4_code], mi_active_property.automatic_geocode_ind =
[dbo_active_property].[automatic_geocode_ind], mi_active_property.county_code
= [dbo_active_property].[county_code], mi_active_property.county_name_text =
[dbo_active_property].[county_name_text],
mi_active_property.total_assisted_unit_count =
[dbo_active_property].[total_assisted_unit_count],
mi_active_property.total_unit_count =
[dbo_active_property].[total_unit_count],
mi_active_property.primary_fha_number =
[dbo_active_property].[primary_fha_number],
mi_active_property.associated_fha_number =
[dbo_active_property].[associated_fha_number],
mi_active_property.associated_contract_number =
[dbo_active_property].[associated_contract_number],
mi_active_property.troubled_code = [dbo_active_property].[troubled_code],
mi_active_property.troubled_status_update_date =
[dbo_active_property].[troubled_status_update_date],
mi_active_property.opiis_risk_category =
[dbo_active_property].[opiis_risk_category],
mi_active_property.opiis_size_category =
[dbo_active_property].[opiis_size_category],
mi_active_property.opiis_int_risk_score =
[dbo_active_property].[opiis_int_risk_score],
mi_active_property.opiis_risk_category_change_dt =
[dbo_active_property].[opiis_risk_category_change_dt];


Also, if you could give some hints on the objects & methods I could use to
do this with VBA I know enough to be dangerous.


Thank you

phil
 
J

John Spencer (MVP)

You need two queries.

An Update Query and an Append query.

The append query would basically be the same as the update query.

INSERT INTO mi_active_property
(mi_active_property.property_id,
mi_active_property.hub_name_text,
...)
SELECT dbo_active_property.property_id,
[dbo_active_property].[hub_name_text],
...
FROM dbo_Active_Property LEFT JOIN mi_activeProperty
Hello,

I need some help with this problem please.

BACKGROUND
I need to update a local copy of a national database once a day. I link to
the national database through ODBC drivers. I created an update query which
works great as long as the information is already in the local copy, but if
new information for my region is put into the national database, I do not get
the new information updated into my local copy.

DETAIL
national database
all states of the U.S.A
local database
just MICHIGAN U.S.A.

SQL QUERY

UPDATE DISTINCTROW dbo_active_property INNER JOIN mi_active_property ON
dbo_active_property.property_id = mi_active_property.property_id SET
mi_active_property.hub_name_text = [dbo_active_property].[hub_name_text],
mi_active_property.servicing_site_name_text =
[dbo_active_property].[servicing_site_name_text],
mi_active_property.project_manager_name_text =
[dbo_active_property].[project_manager_name_text],
mi_active_property.property_id = [dbo_active_property].[property_id],
mi_active_property.property_name_text =
[dbo_active_property].[property_name_text],
mi_active_property.address_line1_text =
[dbo_active_property].[address_line1_text],
mi_active_property.address_line2_text =
[dbo_active_property].[address_line2_text], mi_active_property.city_name_text
= [dbo_active_property].[city_name_text], mi_active_property.state_code =
[dbo_active_property].[state_code], mi_active_property.state_name_text =
[dbo_active_property].[state_name_text], mi_active_property.zip_code =
[dbo_active_property].[zip_code], mi_active_property.zip4_code =
[dbo_active_property].[zip4_code], mi_active_property.automatic_geocode_ind =
[dbo_active_property].[automatic_geocode_ind], mi_active_property.county_code
= [dbo_active_property].[county_code], mi_active_property.county_name_text =
[dbo_active_property].[county_name_text],
mi_active_property.total_assisted_unit_count =
[dbo_active_property].[total_assisted_unit_count],
mi_active_property.total_unit_count =
[dbo_active_property].[total_unit_count],
mi_active_property.primary_fha_number =
[dbo_active_property].[primary_fha_number],
mi_active_property.associated_fha_number =
[dbo_active_property].[associated_fha_number],
mi_active_property.associated_contract_number =
[dbo_active_property].[associated_contract_number],
mi_active_property.troubled_code = [dbo_active_property].[troubled_code],
mi_active_property.troubled_status_update_date =
[dbo_active_property].[troubled_status_update_date],
mi_active_property.opiis_risk_category =
[dbo_active_property].[opiis_risk_category],
mi_active_property.opiis_size_category =
[dbo_active_property].[opiis_size_category],
mi_active_property.opiis_int_risk_score =
[dbo_active_property].[opiis_int_risk_score],
mi_active_property.opiis_risk_category_change_dt =
[dbo_active_property].[opiis_risk_category_change_dt];

Also, if you could give some hints on the objects & methods I could use to
do this with VBA I know enough to be dangerous.

Thank you

phil
 
Top