2

I would like to combine these queries:

UPDATE T1
SET Opening_date = T2.Opening_date
FROM FactTransaction T1
INNER JOIN DimStore T2 ON T1.cod_Store = T2.Cod_StoreKey

and

UPDATE FactTransaction
SET ORDINAL = DATEDIFF(DAY, Opening_Date, DATE)

In order to avoid insert the field Opening_date in my fact table. I don't know how to do it just with a query.

3
UPDATE T1 SET 
Opening_date = T2.Opening_date, 
ORDINAL = DATEDIFF(DAY, T2.Opening_Date, T1.DATE) 
FROM FactTransaction T1 
INNER JOIN DimStore T2 ON T1.cod_Store = T2.Cod_StoreKey;

...if I understand you correctly.

Edit: Ok, just go with:

UPDATE T1 SET 
ORDINAL = DATEDIFF(DAY, T2.Opening_Date, T1.DATE) 
FROM FactTransaction T1 
INNER JOIN DimStore T2 ON T1.cod_Store = T2.Cod_StoreKey;
  • yeah, the thing is that my fact table does not have the field "opening_date" which is on DimStore. So I want to get the datediff between Date (Factable) and Opening_date (DimStore) – Miguel Sep 23 '15 at 10:55
  • Edited... Try that. – Rob Farley Sep 23 '15 at 11:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.