How to quickly insert tens of thousands of data into a table in the database

Let me share with you how to quickly create tens of thousands of pieces of data from a table in the database. I use the Sql serve database, and now create a table in the database. (casually built)

create table Info
(
Id int primary key identity(1,1),
Names  nvarchar(100),
Num int

)

Let's start adding data and use the while loop method.
declare @i int
set @i=0
while(@i<30000)
begin
set @i=@i+1
insert into Info values('product name'+CONVERT(nvarchar(100), @i), @i)
end

@i is a variable that you set at will, to accept the value that increases each time

CONVERT is for type conversion, and the type to be converted is written in it.

select COUNT(Id) from Info It can be seen that a total of 30,000 pieces of information have been found.



Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325735214&siteId=291194637