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.
| Author |
Topic |
|
satya068
Posting Yak Master
233 Posts |
Posted - 2010-05-20 : 09:39:36
|
| Hi..i am comparing two tables T1 aand T2,i am supposed to get same no_of records in both tables.but in T1 50 and T2 57now i want to find in which column got exxcess records in table T2i checked the key_code column for any duplicates using the below sql there are no duplicates in the key_code column.select * from(select KEY_CODE, count(*) as cntfrom Employee_idgroup by KEY_CODE) inqwhere cnt > 1is there any other way to find that records in T2?would you guys have any idea about this please?thanx in advance.Satya |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2010-05-20 : 09:59:11
|
If both tables have exact same key_codes, below query compares both tables to find extra records in t2:select t2.* from Employee_id2 t2 left join Employee_id1 t1on t2.key_code = t1.key_codewhere t1.key_code is null Harsh Athalyehttp://www.letsgeek.net/ |
 |
|
|
satya068
Posting Yak Master
233 Posts |
Posted - 2010-05-20 : 10:12:03
|
| Thanx harsha.Satya |
 |
|
|
|
|
|