Solved

compare data

Posted on 2011-02-12
4
389 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

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.
A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

751 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