tags:

views:

59

answers:

2

Hey guys, so I have two tables. They are pictured below.

I have a master table "all_reports". And a user table "user list". The master table may have users that do not exist in the user list. I need to add them to the user list.

The master table may have duplicates in them (check picture). The master list does not contain all the information that the user list requires (no manager, no HR status, no department.. again check picture).

so in summary, distinct users from master table that do not exist in user table need to be migrated over. Only fields that are common to them is recipient ID, and recipient name

This is the MASTER TABLE

this is the user table

A: 
Insert into user_table(recipient ID, recipient_name)
SELECT recipient ID, recipient_name from master_table as m
where not eixts(select * from user_table 
where recipient ID=m.recipient ID and recipient_name=m.recipient name)
Madhivanan
+1  A: 
INSERT INTO User_List
(RecipientId)
SELECT DISTINCT recpid
FROM All_Reports ar
LEFT OUTER JOIN User_List ul
ON ul.RecipientId = ar.recpid
WHERE ul.RecipientId IS NULL

You'll need to modify it to get the LastName, FirstName, etc from wherever the source for those will be.

Paul Kearney - pk