all groups > sql server data warehouse > august 2004 >
You're in the

sql server data warehouse

group:

Updating Datamart???


Updating Datamart??? Steve
8/6/2004 12:21:08 AM
sql server data warehouse:
Hi,
I am building datamart but I need your expert advise to
update the datamart.
I get text file & load it into Staging Table. From
Staging Table I load it into Dimension table

Cust_Staging_Table

Cust_id Cust_Name Cust_Add Cust_City
111 Sam 100 St. San Jose
222 Maria 7th Ave Hollywood
333 kathy 5th St. Dallas
444 Nicole 1st Ave Arlington




Cust_Dimension_Table

Cust_wk Cust_id Cust_Name Cust_Add Cust_City
1 111 Sam 100 St. San Jose
2 222 Maria 7th Ave Hollywood
3 333 kathy 5th St. Dallas
4 444 Nicole 1st Ave Arlington


Now I get a new text file for customer table with info.
changed. For example Maria's address has changed. I
truncate the previous info in Customer_Staging_Table &
load this new info from text file.

Cust_Staging_Table

Cust_id Cust_Name Cust_Add Cust_City
111 Sam 100 St. San Jose
222 Maria 44th Ave Burbank
333 kathy 5th St. Dallas
444 Nicole 1st Ave Arlington

To make this info. in sync with my Cust_Dimension_Table,
I use the following update statement


Update Cust_Dimension_Table

set
Cust_Dimension_Table.Cust_Name =
Cust_Staging_Table.Cust_Name

Cust_Dimension_Table.Cust_Add =
Cust_Staging_Table.Cust_Add

Cust_Dimension_Table.Cust_City =
Cust_Staging_Table.Cust_City

where
Cust_Dimension_Table.Cust_id = Cust_Staging_Table.Cust_id

In my datamart I have more than 200000 records. Any
info. can change regarding a particular column. Is there
an effecient way of updating the dimension table. (Shall
I use views/temp tables). Can anyone please show me the
effecient solution for update with above example.

Thanks

Steve






Re: Updating Datamart??? Lic. Nery R. Gonzalez
8/6/2004 6:16:41 PM
Hi Steve!!

Try this out

Update d set d.Cust_Name = s.Cust_Name
d.Cust_Add = s.Cust_Add
d.Cust_City = s.Cust_City
From Cust_Dimesion_Table d Inner Join Cust_Staging_Table s
On d.Cust_id = s.Cust_id
where (d.Cust_Name Not Like s.Cust_Name) Or (d.Cust_Add Not Like
s.Cust_Add) Or (d.Cust_City Not Like s.Cust_City)


Just in case any of the fields changes...


[quoted text, click to view]

AddThis Social Bookmark Button