Table 1
ID Int 4 0
R_name Nvarchar 20 1
R_class Nvarchar 20 1
R_p Int 4 1
R_p1 Int 4 1
R_p2 Money 8 1
R_p3 Money 8 1
R_type Int 4 1
R_color Varchar 7 1
R_remark Nvarchar 200 1
R_max Int 4 1
Table 2
ID Int 4 0
R_id Int 4 1
X_id Int 4 1
X_p Money 8 1
X_p1 Money 8 1
X_p2 Money 8 1
X_p3 Money 8 1
Table 1 Data
Id R_p r_p1 r_p2 r_p3
1 1 12 23 34
2 45 56 57 58
3 76 89 92 99
......
100 356 234 231 213
Table 2 no data
Objective: To copy ID, R_p, r_p1, r_p2, r_p3, r_p4 from table 1 to r_id, x_p, x_p1, x_p2, x_p3 of table 2, and x_id is fixed. It is convenient to initialize some values from a table.
Insert Into Table 2 (x_id, r_id, x_p, x_p1, x_p2, x_p3) Select 1 , ID, R_p, r_p1, r_p2, r_p3 From Table 1
After copying:
Table 2
Id x_id r_id R_p r_p1 r_p2 r_p3
1 1 1 1 12 23 34
2 1 2 45 56 57 58
3 1 3 76 89 92 99
......
100 1 100 356 234 231 213
The essence of this statement cannot be described in languages due to poor writing.Code.