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.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 How to get updated values by joining two tables?

Author  Topic 

aex
Yak Posting Veteran

60 Posts

Posted - 2006-05-23 : 01:47:12
Hi, i hv two tables which of same structure, say table A and table B, and there are 10 rows for each of the table respectively. My problem here is i want to make a comparison between these two tables and i want to return those rows that are updated in table B only.

Any solution? thanks.

aex

Kristen
Test

22859 Posts

Posted - 2006-05-23 : 01:56:08
[code]
SELECT 'B---------->', B.*, CHAR(13)+CHAR(10)+'A---------->', A.*
FROM TableB AS B
LEFT OUTER JOIN TableA AS A
ON A.PKCol = B.PKCol
WHERE A.PKCol IS NULL
OR (A.Col1 <> B.Col1
OR (A.Col1 IS NULL AND B.Col1 IS NOT NULL)
OR (A.Col1 IS NOT NULL AND B.Col1 IS NULL))
OR ... repeat column Col2, COl3 ...
[/code]
Kristen
Go to Top of Page

aex
Yak Posting Veteran

60 Posts

Posted - 2006-05-23 : 04:19:25
Thanks Kristen for the reply. I've finally got what i want. your reply is highly appreciated and it helps to solve my problem. thanks.

aex
Go to Top of Page
   

- Advertisement -