表1
id(PK)| name | age
表2
姓名|年龄
aaa | 25
bbb | 25
ccc | 20
结果:
id(PK)| name | age
1 | aaa | 25
2 | bbb | 25
3 | ccc | 20
如何从select table2插入table1,其中tabel1中的列(id)为(PK)
我用过这个
Load_check_pieces2_true(Max_check_id2)
For x As Integer = 1 To dt_chex_pieces2_true.Rows.Count
Max_Orderid = Max_order_id() + x
insert_Orders(Max_Orderid, Max_shift_id, dt_chex_pieces2_true.Rows(x)("check_id").ToString)
Next
答案 0 :(得分:0)
插入table1时,在插入脚本上方使用以下选项: SET IDENTITY_INSERT [dbo]。[Table1] ON;
INSERT INTO()values();
这将解决您的问题。