Need to port data in sql table
I have a master table with columns (masterid, masterdata, year). Here masterid is an identity column.
I have the data for year 2012. I need to same 2012 data for 2013
I could solve the problem by simply running a SQL statement like:
INSERT INTO mastertable
SELECT masterdata, 2013
FROM mastertable WHERE Year = 2012
I would like to run similar kind of run for child table also.
My child table structure is: (childid , masterid, childdata)
Here I have child data for the year 2012, I want to have similar data for year 2013 with proper masterid created for master data for the year 2013 in first step.
Preferably I would like to have solution without adding additional temporary columns
Any lead greatly appreciated.
Regards,
Kumar.
You’ll need to store the links between the 2013 and 2012 records created in the
mastertabletable. If you want to achieve this without adding any additional temporary columns you’ll need to use T-SQL.(I’ve guessed a type of
varchar(max)for masterdata as you haven’t specified its type).