1

I need to migrate some data from access to sql.

access has one table: tblMakeModel with two fields: make, model

I am making two tables in SQL

  • tblMake: id, make

and

  • tblModel: id, makeID, model

I've moved the makes over, but now i can't figure out how to migrate the models to match up with the makeIDs, since I am recreating ID's, how do i match them up?

please help

1 Answer 1

2

(I'm assuming that the IDs are database-generated integers).

Bring the entire table into the SQL Server database and call it tblMakeModel (just like in the original). Then:

 INSERT INTO tblMake (Make) SELECT DISTINCT Make FROM tblMakeModel

 INSERT INTO tblModel (MakeID, Model) 
    SELECT DISTINCT M.MakeID, MM.Model 
    FROM tblMakeModel MM INNER JOIN tblMake M ON MM.Make = M.Make

 DROP TABLE tblMakeModel

If the IDs are not a sequence, then you'll need to edit the tblMake table after the first command to contain the new IDs and then run the other two commands, then add the IDs to the tblModel table. In this case, you'll need to remove the PK constraint on both tables until you finish your work.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.