This article describes how to quickly insert multiple data into a data table to meet the needs of SQL statement learning or project testing.
This article is not original, is the re-collation of the original.
If you have the following form,
1, the original way to add records, SQL statements are as follows:
1 Insert INTO city (Code,citycname) VALUES ('TS',' tangshan ');
2, using the Union to perform interpolation operations, SQL statements are as follows:
1 2 select'ZZ',' Zhengzhou '3 4 Select'HD', ' Handan '
3,sql Server 2008, the SQL statements are as follows:
1 Insert INTO City (code,citycname)2 values ('XT',' Xingtai '), ('SJZ',' shijiazhuang ');
Above, the query results are as follows:
4, declare the variable, insert multiple records in a single time, the SQL statement is as follows:
1 int 2 set @i=13while @i<=4 begin 5 Insert INTO City (code,citycname)6 values (@i,@i)7 set @[email protected]+18 End
The query results are as follows:
SQL inserts more than one record at a time