Solved

compare data

Posted on 2011-02-12
4
387 Views
Last Modified: 2012-05-11
How to compare data between two table? I want to compare if account and date on two table if are the same<br />Table1<br />ID account order date <br />Table2<br />ID account order date<br />
0
Comment
Question by:VBdotnet2005
  • 2
4 Comments
 
LVL 23

Expert Comment

by:wdosanjos
ID: 34879523
Something like:

Select t1.accountid, t1.orderdate, t2.orderdate from t1, t2 where t1.accountid = t2.accountid and t1.orderdate <> t2.orderdate

0
 
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 34879540
use third party tools like red-gate data compare and apex data compare
http://www.red-gate.com/products/sql-development/sql-data-compare/
otherwise
compare the count *
then
select count(*) from ( select * from table1 union select * from table2 ) a  -- if it is the same then the tables are same

0
 
LVL 75

Accepted Solution

by:
Anthony Perkins earned 250 total points
ID: 34879620
Something like this perhaps:
SELECT *
FROM	Table1 t1
	FULL OUTER JOIN Table2 t2 ON t1.ID = t2.ID
WHERE	t1.Account <> t2.Account 
	OR t1.OrderDate <> t2.OrderDate
	OR t1.ID IS NULL
	OR t2.ID IS NULL

Open in new window

0
 
LVL 23

Assisted Solution

by:wdosanjos
wdosanjos earned 250 total points
ID: 34880184
Sorry I misread your question. Here is the correct script.  The first one lists the records with different order dates.

Select t1.accountid, t1.orderdate, t2.orderdate from t1, t2 where t1.accountid = t2.accountid and t1.orderdate = t2.orderdate

Open in new window

0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question