insert into usage

1, the simplest engage in law

create table test(
  keyid int identity,
  sort varchar(10),
  qty int
) 
insert into test (qty2,sort2) values (1,'e') 

2, inserting a plurality of values, to insert multiple records of the wording or better

insert into test(qty,sort) values (1,'a') ,(2,'a'),(3,'b'),(8,'c'),(9,'c') 

3, the assignment of other values ​​in the table, pay attention to the type and size

insert into  test(qty,sort)  select  qty2,sort2 from test2  --不加条件是全部复制,
语法:  insert into  表(字段,字段)  select  字段,字段 from 表 

Guess you like

Origin blog.csdn.net/weixin_42780928/article/details/91867378