Quote:
I'm trying to do an insert of some new records and my source is a flat text file that is length delimited.
It contains one record per row except for the primary key field, an integer which is not null and PK.
|
I couldn't understand well the explanation.
One reason might be inappropriate words(e.g. record, flat text file) were used in the explanation.
Another reason might be my poor English capability.
(What is "It"? my.source? or my.desttable?)
So, I'll ignore that.
Looking into the Code, it would be changed like this:
Code:
INSERT INTO my.desttable
SELECT
(SELECT max(id) FROM my.desttable)
+ rn
, col1
, col2
FROM
(SELECT
col1
, col2
, ROW_NUMBER() OVER() AS rn
FROM
my.source
) q
;