Thursday, March 8, 2012

Compare data between 2 tables

I have 2 tables in SQL server. They have the same data structure. Table A
has more records than Table B. I would like to know how I should write a
sql statement to find out the missing records from Table B compare to Table
A. Thanks!
ChrisChris,
> I have 2 tables in SQL server. They have the same data
> structure. Table A has more records than Table B. I would like
> to know how I should write a sql statement to find out the
> missing records from Table B compare to Table A. Thanks!
select * fom TableA
where not exists (select * from TableB
where TableA.keycol = TableB.keycol)
Linda|||Assume the two tables under considerations are
Table 1 => A (col1,col2,col3
Table 2 => B (col1,col2,col3
A has more records than
select * from TABLE
WHERE col1 not exists (select col1 from table B|||you could use an Application and then you can do it
quickly any time for any table you want. Check out
www.dbghost.com
>--Original Message--
>I have 2 tables in SQL server. They have the same data
structure. Table A
>has more records than Table B. I would like to know how
I should write a
>sql statement to find out the missing records from Table
B compare to Table
>A. Thanks!
>Chris
>
>.
>

No comments:

Post a Comment