Table A contains data. CREATE TABLE A (Employee varchar(20) NULL, Phone varchar(10) NULL, ID1 int )INSERT A ( Employee, Phone, ID1)VALUES ('John', '8139985434' , 1)INSERT A ( Employee, Phone, ID1)VALUES ('Mary', '8139453409' , 2)INSERT A ( Employee, Phone, ID1)VALUES ('Jane', '7185432341' , 3)Sample table:Employee Phone ID1John 8139985434 1Mary 8139453409 2Jane 7185432341 3
The table contains 3 records, but if any of the records has an ID of 2 I need to break that record out into 2 records. Ex: The Mary record has an ID of 2 so I need to create 2 Mary records. One of the Mary records needs to have an ID of 5 and the other 6. So the result table B would look like this:Employee Phone ID2John 8139985434 1Jane 7185432341 3Mary 8139453409 5Mary 8139453409 6
Is there any easy way of doing this? Do I need to loop through table? Can I use something other than a cursor? I would appreciate any help.Thanks,Ninel