Member Avatar for mrkm1188

I have two tables of employee information from two different sources, one from Active Directory and one from our Billing Department.

The AD table has the following columns:
EmployeeID
Surname
Givenname
Company
Office.

The Billing Dept table thas the following columns:
EmployeeID
Company
Office
First
Last.

I want to compare the elements in each table and generate a table with the differences from both. Thanks for the help in advance.

Sounds like you want to implement a full join. A full join will include records from both tables where there is a match in at least one table. Here is an example of how to implement it.

http://www.itgeared.com/articles/1169-sql-full-join/

Member Avatar for mrkm1188

Let me rephrase. I want one table as a result that contains the rows from each table that should be the same but have a field that is different
For example: If there are two rows that have the same employee ID but different names, then i want the row from the first table followed by the row from the second table so i can see the differences.

select ad.EmployeeID,
ad.Surname,
ad.Givenname,
ad.Company,
ad.Office ,

BD.EmployeeID,
bd.Company,
bd.Office,
bd.First,
bd.Last
from ad inner join bd on ad.employeeid =bd.employeeid
where (ad.surname<>bd.last or ad.givenname<>bd.first or ad.company<>bd.company or ad.office<>bd.office)
Member Avatar for mrkm1188

That worked. Thank you very much.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.