SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Comparison of 2 tables
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Mmm
Starting Member

2 Posts

Posted - 07/13/2013 :  06:05:32  Show Profile  Reply with Quote
Hi,

need some help :) I am fairly new to this so please bear with me.

I am doing this 2 queries, they get data from the same tables in a very different way. The new way is a lot faster but of course there are problems. There are some discrepancies in the results. Both queries produce results with more than 200.000 rows. Second one has ca. 100 rows less than the first one and some of the results are wrong (most are correct though).

My question is how do I find the differences. I did the left outer join when column a.result != b.result (lines are defined by date and ID so they should be unique).

but the join gives me problematic results (some are not different at all, some differences are not in the result).

so how do I find the differences between 2 queries, including missing results/rows?

Thanks in advance for help :)

Mmm

SwePeso
Patron Saint of Lost Yaks

Sweden
30282 Posts

Posted - 07/13/2013 :  06:30:06  Show Profile  Visit SwePeso's Homepage  Reply with Quote
SELECT * FROM dbo.Table1 AS t1 WHERE NOT EXISTS (SELECT * FROM dbo.Table2 AS t2 WHERE t2.Date = t1.Date AND t2.ID = t1.ID)

Also see http://weblogs.sqlteam.com/peterl/archive/2007/09/20/Finding-records-in-one-table-not-present-in-another-table.aspx



N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

Sweden
30282 Posts

Posted - 07/13/2013 :  06:31:20  Show Profile  Visit SwePeso's Homepage  Reply with Quote
And this http://weblogs.sqlteam.com/peterl/archive/2009/06/12/Timings-of-different-techniques-for-finding-missing-records.aspx



N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

Mmm
Starting Member

2 Posts

Posted - 07/13/2013 :  08:03:41  Show Profile  Reply with Quote
Thank you for the swift reply :)

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000