First, insert data
1.insert Statement Introduction
Insert into table_name (COLUMN1,COLUMN2 ... column)values(Value1,value2,......valuen)//column1,column2......column represent columns to add data records, separated by commas between columns; value1, Value2,......valuen indicates the specific value to add the record to.
Follow the principles:
1) The data type of the inserted data must be the same as the data type of the added field;
2) The size of the inserted data should be within the range of the field definition length;
3) in values, the data location that is listed must correspond to the position where the field is arranged.
2. Inserting data into some fields in the datasheet
Insert into Values (5,98005,' jiang Hua ',' Jilin province Liaoyuan ') Select * from T_stud
3. Inserting data into all fields in the datasheet
Law One:
Insert into Values (5,98005,' lily ',13658974563,' Jilin province Siping ' )Select* from T_stud
Law II:
Insert into Values (4,98004,' jianghua ',13633569956,' Jilin province Liaoyuan ' )Select* from T_stud
3. Inserting query data into another data table
(1) INSERT INTO select mode
Insert into table_name1 (COLUMN1,COLUMN2......COLUMNN)// Specify data table name for insert data Select// Specify the source field for the inserted data from // Specifies the source table name of the inserted data where // represents a query condition expression
Example: Insert id,xh,xm three columns from the T_stud table into the new table.
Create TableT_stud_bak (Tiddecimal(8) not NULL, TxhChar( -), TxMChar( -))Insert intoT_stud_bak (TID,TXH,TXM)SelectId,xh,xm fromT_studSelect* fromT_stud_bak
(2) SELECT INTO mode
Select INTO fromwhere
Example: Inserting Xm,lldh,jtdz from a t_stud table into a new table
Select Xm,lldh,jtdz into T_stud_back from T_stud Select * from T_stud_back
The difference, the way one needs to create an empty table first, the way two does not need.
T-SQL statement 4