Reputation: 87
Table A has historical records. Table B has 100 new records.
I need to append the data from Table B to Table A. Table A was built with a Row Number(using the Row_Number function) The last record entry had a row number of 100, how do I append my new data into that table and continue the row record to 101 and so on?
Upvotes: 0
Views: 664
Reputation: 43646
Maybe something like the following:
BEGIN TRAN
DECLARE @MaxValue INT;
SELECT @MaxValue = MAX([record_id])
FROM TableA;
INSERT INTO TableA
SELECT ROW_NUMBER() OVER (ORDER BY (SELECT 1)) -- or order by something else you need
+
@MaxValue
,*
FROM TableB
COMMIT TRAN
Upvotes: 1