INSERT and UPDATE in T-SQL
1、SELECT INTO:
Select vale1, value2 into table 2 from table 1
--The target table Table2 does not exist. When inserting, Table2 will be automatically created, and the specified field data in Table1 will be copied to Table2 SELECT vale1, value2 into Table2 from Table1.
2、INSERT INTO:
Statement form: Insert into Table 2(field1, field2,...) select value1,value2,... from Table 1
--Target Table2 must exist. Since target Table2 already exists, we can insert constants Insert into Table2(field1,field2,field3,field4) select value1,value2,'character constant', number N from Table1 in addition to fields from source Table1.
3、UPDATE:
Name form:
update table set field1= field value 1,field2= field value 2 where field3= field value 3update table A set field1= table B.fieldx from table A, table B where table A.id= table B.id and table A. field 1= field value and table B. field 1= field value
Form 1 updates according to conditions; Form 2 updates data from Table B to Table A