If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > compare two tables records using cursour

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-30-09, 16:42
itsdba itsdba is offline
Registered User
 
Join Date: Dec 2009
Posts: 1
compare two tables records using cursour

I have 2 tables having one common coloumn in both. How can I comapre that the both col conatin same value or not. How can I do this using cursor?
If any other way to resolve this

Please help me on that.
Reply With Quote
  #2 (permalink)  
Old 12-30-09, 18:55
r937 r937 is online now
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,085
let's say your two tables are called table1 and table2, and the column that they have in common is called columnx

this query compares the rows without a cursor --
Code:
SELECT table1.columnx
     , table2.columnx
  FROM table1
FULL OUTER
  JOIN table2
    ON table2.columnx = table1.columnx
ORDER
    BY COALESCE(table1.columnx,table2.columnx)
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On