编写sql server存储过程中,
需要向A表批量插入数据,
但A表主键整型非自增长,
请教各位大虾有什么好的方法插入数据,
并确保线程安全呢?
table1_id为Table1主键且非自增
table2_id为Table2主键
insert into table1 (table1_id) select (select isnull(max(table1_id),0) from table1)+row_number() over(order by table2_id) from table2