0

So the situation is as follow:

I have production DB called DB1 which has huge data, around 250 GB. I have Test DB called DB2 on my local machine which has the same schema as the production DB but only the first two tables are partially filled(UUT_RESULT, STEP_RESULT).

What I want: Copy the only related data from the Production DB tables (PROP_RESULT) to my local DB table.

Very important note: I can copy the entire table, However, it's huge. That's why I only want to copy the data from PROP_RESULT table in the production DB which has relation to the already existed data in my local DB.

Note: Only UUT_RESULT and STEP_RESULT are partially filled in the Local DB, other tables are empty and I need to populate them and that's why I am posting this.

The following image will make is easier to understand

enter image description here

0

This could probably be done with some ETL tool but A manual way comes to mind: - just join the test tables together ( I'm guessing the join condition would be STEP_RESULT.UUT_RESULT = UUT_RESULT.ID) to get all the relevant keys.

SELECT a.ID 
FROM STEP_RESULT a join UUT_RESULT b 
on a.UUT_RESULT = b.ID

So lets say you get a 1000 values of b.ID. Then manually create a select which will have all the values returned from the TEST sql in an IN condition and run it on PROD:

SELECT * FROM PROP_RESULT WHERE STEP_RESULT IN ('ID1','ID2', ...)

Not sure how exporting data in MSSQL works but I'm guessing you could just save that select as a separate table and then just load it into your TEST environment

|improve this answer|||||
  • the JOIN (STEP_RESULT.UUT_RESULT = UUT_RESULT.ID) is true. however, it gives me the shared between the first two tables. How can I get the shared with prob table which is in different DB? I didn't get the second part of your answer. Could you please elaborate morre. – Nano Jul 18 '19 at 13:05
  • by that I mean you manually copy all the keys from the select in TEST, and create a select in PROD which you run there. I changed my answer slightly, hopefully it is more clear now – d0dulk0 Jul 22 '19 at 16:02

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.