Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Table comparisons

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2004-09-21 : 08:39:26
Deepak writes "I have created two tables Employee_hours_1 and Employee_Hours_2 using one SQL Select query having the same criteria. Both the tables have same data but different counts.

I would like to analyze the table with a query both the tables to find out which records are in one table and not in other?

Employee_hours_1


Name,Soc_sec, Hours, desc, Comment

Employee_hours_2

Name,Soc_sec, Hours, desc, Comment

Thanks

Deepak"

rockmoose
SQL Natt Alfen

3279 Posts

Posted - 2004-09-21 : 08:46:02
one technique:
select ... from
t1 left join t2 on t1.key1 = t2.key1 and t1.key2 = t2.key2 and ...
where t2.xxx is null

you might even use a full join to see wich records are in t1 but not t2 or in t2 but not in t1.

rockmoose
/* Chaos is the nature of things...Order is a lesser state of chaos */
Go to Top of Page

ffoiii
Starting Member

12 Posts

Posted - 2004-09-22 : 00:09:25
select t1.*, t2.*
from t1 full outer join t2 on t1.key1 = t2.key1 and...
where t1.key1 is null or t2.key1 is null


ffoiii
Go to Top of Page
   

- Advertisement -