How to compare 2 tables with different keys?
GeeOh
Posts: 4 New member
Hi,
I am trying to compare 2 data warehouse fact tables across our Pre-prod and Production environments.
The issue is that the fact table keys are generated randomly in each environment as the data isnt ordered when it hits the dimensions for key creation.
The obvious choice would be to create views containing the business keys/data by joining the facts to the dimensions, however creating views on production environment is limited.
Is there another way I can achieve this through Data Compare Pro? - I'm thinking a custom query that is ran against the 2 environments and then the results of the query are compared.
Thanks.
Tagged:
Answers
There isn't a facility within the product to compare the results of a script that is run I'm afraid -unless you dumped the results from source and target into new tables that is.
Regarding the keys - is it that the columns and keys are not named and ordered the same? Are you not able to map the columns and choose a custom key to compare on between two (or more) columns that make a unique record to make the comparison? See this page for more details on mapping columns and setting the comparison key: https://documentation.red-gate.com/sdc/setting-up-the-comparison/selecting-tables-and-views
Kind regards,
Alex
Have you visited our Help Center?
Thank you for the clarification! I think it may have just taken a minute for it to post or it needed to be approved, but it's there now and that makes more sense.
You would need some way to map the values of the key 45>1, 75>2, 63>3 to be able to compare the FactA tables to each other, rather than mapping the column "Key" to another column (which is what is what I thought you had meant).
The only way for this to work (as you have ascertained) is going to be via a view that gets the result as you have shown at the bottom of the image since the values need to match for the rows to be compared.
There are two suggestions on the SQL Data Compare Uservoice forum similar to your request, so it would be good for you to vote on those and comment as well to elaborate on the situation here where it would help!
https://redgate.uservoice.com/forums/147879-sql-data-compare?query=query
Kind regards,
Alex
Have you visited our Help Center?