I'm working in SQL Server 2012. I need to migrate data from one table to another, but I need to duplicate the data as well. Here is the setup:
Table A has a 1 to many relationship to Table B. Some of the data in each record in Table A needs to be moved to multiple records of Table B related to the Table A record. Each record in Table A needs to copy its data into multiple records of table B for any records in Table B that links to a given Table A record.
I need a way to do this with one single SQL UPDATE if at all possible. And I need to understand how the SQL works. I've not been able to find a way to do this through Google or searching SO.
Table A:
ID : int
Name : varchar2
Age : int
Type_ID : int
Rating : int
Table B:
ID : int
Table_A_ID : int
Name : varchar2
Age : int
Subject_ID : int
Note : varchar2
So in this example Age and Name need to be copied from Table A to all records of Table B that share Table_A_ID with Table A's ID field. Once the migration is successful, I will remove Name and Age from Table A.