SQL inserts data in bulk
Summary of sql statements for bulk insert data in MS SQL Server database:
The first kind:
Insert into tb_NameList (Name,InsertDate,UpdateDate)
Values ('aa',GETDATE (), GETDATE ())
Insert into tb_NameList (Name,InsertDate,UpdateDate)
Values ('bb',GETDATE (), GETDATE ())
Insert into tb_NameList (Name,InsertDate,UpdateDate)
Values ('cc',GETDATE (), GETDATE ())
In this way, all the statements are written and executed at once, which is actually the same as a single insert.
The second kind:
Insert into tb_NameList (Name,InsertDate,UpdateDate)
Values ('aa',GETDATE (), GETDATE ()), (' bb',GETDATE (), GETDATE ())
('cc',GETDATE (), GETDATE ())
This can write a lot less SQL statements, as long as the order of the Values is written clearly on OK.
The third kind:
Insert into tb_NameList (Name,InsertDate,UpdateDate)
Select 'dd',GETDATE (), GETDATE () union all
Select 'ee',GETDATE (), GETDATE () union all
Select 'ff',GETDATE (), GETDATE ()
With the help of union all, it is said to be faster than the second one, but the field is simple and the effect is not obvious with less data.