Yes, use both.
First check to see how bad the problem is, how many folks have the same names. Then find some way to identify them uniquely based on other fields.
Check for same name, different person.
Code:
SELECT Fname, Lname, COUNT(*)
FROM tableA
GROUP BY Fname, Lname
HAVING COUNT(*) > 1
Do this also for tableB.
Manually examine the data you have on these people and find a way to distinguish them, with any luck you will find one of two other fields that do this. For convenience in the following, I will call this field columnX, but it might be two or three columns.
Code:
SELECT Fname, Lname, columnX, COUNT(*)
FROM tableA
GROUP BY Fname, Lname, columnX
HAVING COUNT(*) > 1
When this query returns no rows, you have a set of columns (fields) which identify the employees uniquely. These are the fields you will use to match rows from the two tables.
To compare the two tables you could replace employeeID with these several columns in an outer join(LEFT JOIN).
Code:
SELECT tableB.*
FROM tableB
LEFT JOIN tableA
ON tableA.Fname = tableB.Fname
ON tableA.Lname = tableB.Lname
ON tableA.columnX = tableB.columnX
WHERE tableA.Fname IS NULL
This query will yield the rows from tableB which do not have a matching row in tableA.
You should obtain exactly the same result by concatenating the several columns used in the match.
Code:
SELECT *
FROM tableB
WHERE Fname + Lname + columnX NOT IN (
SELECT Fname + Lname + columnX
FROM tableA
)
If so, then you can
Code:
DELETE tableB
WHERE Fname + Lname + columnX NOT IN (
SELECT Fname + Lname + columnX
FROM tableA
)
If the matching columns are not all Text datatypes then you will need to convert them to strings using CStr().
Code:
DELETE tableB
WHERE Fname + Lname + CStr(columnX) NOT IN (
SELECT Fname + Lname + CStr(columnX)
FROM tableA
)
Lesson Learned: Every table should have an id column.