sql- data migraion

Hi,

I am migrating data from TableA to TableB:
TableB and A have same Columns plus tableB as some extra columns which are foreign key from other tables.

total number of records in tableA is 1000 and total number of records in tableB is 999.

How can I find out which one is the record that is not migrated from tableA to table B?

I have tried left join/right join but did not work.

Thanks in advance
shmzAsked:
Who is Participating?
 
sachinpatil10dCommented:
Try this


select Number, desc from TableA
Except
Select Number, desc from TableB

Open in new window

0
 
Brian ChanDBACommented:
You can script a left outer join on the tables with its primary keys. like following:

SELECT A.primaryKey, B.primaryKey
FROM TableA A
LEFT OUTER JOIN TableB B 
On TableA.primaryKey=TableB.primaryKey
WHERE B.primaryKey is NULL

Open in new window


Then you will find if there is any record from TableA which does not exist in TableB.
0
 
Brian ChanDBACommented:
Oooo...... I missed the bottom bit. When you said left join/right join doesn't work, what do you mean?
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
shmzAuthor Commented:
Sorry, the problem is like this:

TableA

Number (PK)
desc
...

TableB

B_AutoIDPK
Number
desc
....
C_FK
D_FK
0
 
Brian ChanDBACommented:
@shmz, sachinpatil10d's solution is very clean-cut as well.
0
 
shmzAuthor Commented:
Excellent thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.