I have table with a RecordID that is the PK, I'd like to copy one line, to a new line in the same table, but I'd like to use the number of this new line to create a key code I have in table.
I'm using
INSERT INTO mytable ([field 1], [field 2], [field 3], [field 4])
SELECT 'New Data for Field 1', [field 2]+[field 3] + [NewRecordID]
FROM mytable
I tried to use the Row_number function, but it always generate a 1 every time I run the query.
Any ideas of I could do to use the new auto-generated number in my query while I copy the data?
Edit: You'll find on the attached file, my table design, and some data.
The idea is to take the (Program Default) country, to copy it with to a new country. I would like to create, while copying existing data for a new country, take the new RecordID that'll be created when line will created and generate a KeyCovCountry including this new generated number.
答案 0 :(得分:0)
执行此操作的一种方法是将KeyCovCountry
设为计算列。