sql server data warehouse:
Hi,
I am having a problem with my update statement for my
DataMart. (Using example here).
I get text file & load it into TableA in Staging. From
TableA I load it into Dimension TableB as is. Therefore
now I have
TableA
CustomerID Name City Category
---------- ---- ---- -------
ALFKI Maria Berlin A
ANATR Ana Seattle NULL
ANTON Antonio Seattle NULL
AROUT Thomas London B
BERGS Christina Dallas NULL
TableB
CustomerID Name City Category
---------- ---- ---- -------
ALFKI Maria Berlin A
ANATR Ana Seattle NULL
ANTON Antonio Seattle NULL
AROUT Thomas London B
BERGS Christina Dallas NULL
Now I truncate TableA & get a new text file with info.
changed. I load this info in TableA. TableA now has
TableA
CustomerID Name City Category
---------- ---- ---- -------
ALFKI Maria Tokyo A
ANATR Ana Seattle A
ANTON Antonio Seattle A
AROUT Thomas London A
BERGS Christina Dallas NULL
Maria has moved from Berlin to Tokyo. Category col. has
changed. Now I have to update my TableB with changes in
TableA. I write the following update statement but it
doesn't do anything
update B
SET B.Category = A.Category,
B.city = A.city
FROM TableB B, TableA A
WHERE B.customerid = A.customerid
AND b.Category <> a.Category
and b.city <> a.city
--AND b.Category not like a.Category
--and b.city <> not like a.city
I can use the following simple staement but it may be
time consuming & may not be effecient to update more than
200000 records for my Datamart
update B
SET B.Category = A.Category,
B.city = A.city
B.Name = A.Name
FROM TableB B, TableA A
WHERE B.customerid = A.customerid
Please help me with my update statement with above example
Thanks
Steve