Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Data Duplication for Different ID's

Status
Not open for further replies.

mkp2004

Programmer
May 27, 2004
11
US
I have 2 tables.

Table 1

emp_id Duplicated_emp_id
103 501
103 502
103 509
205 717
205 689
316 890
316 790
316 280
316 999


table 2 (Main Table)

emp_id emp_name emp_address
103 Manu adffsdfsd
205 anu dfsdfsdfs
316 vinu rttretre


First step is to check whether there is a corressponding emp_id in table 2
second is to duplicate as shown below.The data gets duplicated for each emp_id 103,205,316 but the data remains the same when

duplicated and only the emp_id changes.Can I do a Dts or is there a way to write a script that the final output looks like
shown below.

Now I need to duplicate the data set for each duplicate_emp_id.the final table should look like...

emp_id emp_name emp_address
103 Manu adffsdfsd
501 Manu adffsdfsd
502 Manu adffsdfsd
509 Manu adffsdfsd

205 anu dfsdfsdfs
717 anu dfsdfsdfs
689 anu dfsdfsdfs

316 vinu rttretre
890 vinu rttretre
790 vinu rttretre
280 vinu rttretre
999 vinu rttretre

Please help me out this...
 
select emp_id as emp_id2
, emp_name
, emp_address
from table2
union
select duplicated_emp_id as emp_id2
, emp_name
, emp_address
from table1
, table2
where table1.emp_id = table2.emp_id

I think this should work.

Regards,

Atomic Wedgie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top