I have 2 tables T1 AND T2
T1 has 10 unique records with a primary key (Identity Seed)
T2 has multiple entires with Foreign Key for each record in T1
T1 has 2 columns : PrimaryKey - DATA
T2 has 2 columns : PrimaryKey - FoeignKey (this FK is the Primary Key of T1)
I need to write a query which will select all the records from T1 and INSERT new entries into itself i.e. T1 ,with the same data,and since PK on T1 is identity seed this will auto generate a new ID, as soon as this new ID is generated I need to JOIN the T2 and INSERT new related records with this new Identity.
I know this will duplicate the data and that is not the concern, this is a one time transaction so the query need not be efficient, but NO Cursors please, it would be best if this can be achieved using SELECT and INSERTS without doing loops using external variables !
Thanks !!
UPDATE : If there is an Entry in T1 does not always suggest that in table T2 there has to be a corresponding entry/entries.
P.S. Im using SQL Server 2005