Archives of the TeradataForum
Message Posted: Mon, 12 Mar 2007 @ 17:29:36 GMT
I have created a table that has a unique id that is incremented by 1 every time a row is inserted.
I started with the following to initially populate the table:
CREATE SET TABLE identity_test , CHECKSUM = DEFAULT ( Test_Index INTEGER NOT NULL, cidpersid integer ); Insert into identity_test select row_number () over (order by cidpersid) ,cidpersid from training.cid_persons;
and then this when doing further inserts:
Insert into identity_test (test_Index, CIDPERSID) Select maxid + 1 ,888888 from (select max(test_index) from identity_test ) a (maxid);
The insert above works fine when only inserting a row at a time, but how can I add a bunch of inserts (i.e. Insert select from another table) and get it to increment the Test_Index, starting at the current max?
|Copyright 2016 - All Rights Reserved|
|Last Modified: 27 Dec 2016|