Not sure I've articulated that well in the title, so here goes...
I have three tables
Table1
ID | NewNames |
---|---|
10 | some row data |
11 | some more row data |
Table2
ID | OldNames |
---|---|
1 | my old data |
2 | and more data |
and
GlobalID (with a single row numeric field)
MaxID |
---|
12 |
I'd like to use a Insert Into Select like below:
INSERT INTO table1 (
ID
,NewNames
) SELECT 'a new id'
,OldNames FROM table2
'a new id' is a numeric value and should equal the (max value + 1) from the GlobalID table.
My problem is I obviously need to keep adjusting the GlobalID table and increase the max for each row as I'm inserting from the Select!
Does that make sense?
Any help appreciated. Using sql server 2016 if that makes any difference. Les
table2
? What is the data type of theID
column intable1
? Is theID
column intable1
supposed to be unique?