Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- find all ids and descriptions from source table that are not in destination table
- -- but already have a matching description in the destination table
- SELECT DISTINCT s.uid, s.desc
- FROM source_db..source_table s
- LEFT JOIN dest_db..dest_table d ON d.uid = s.uid
- WHERE s.delete_flag = 'N' AND d.uid IS NULL AND s.desc IN
- (
- SELECT DISTINCT CONVERT(VARCHAR(MAX), t2.desc) FROM dest_db..dest_table t2
- );
- -- note: must convert "desc" field datatype to varchar from text.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement