sql - i want to insert values from table1 to table2 with incremantal value -
i tried id value not changing, getting value first record , set value rest...
insert table1 (id,b,c,d) (select (select max(id)+1 table1),x,y,z table2 where... )
use identity column. can this:
insert table1 (b, c, d) select x, y, z table2 ...
if don't want use auto-increment column can same effect using adding row number of row instead of adding 1. syntax works in mainstream sql databases (not mysql though):
insert table1 (id, b, c, d) select (select max(id) table1) + row_number() on (order x), x, y, z table2 ...
Comments
Post a Comment