You need two tables with a large number of non-repeating rows for your own test, and the more rows you have, the better. Manually write SQL statements that insert data into a table in batches by looping, taking into account the avoidance of a consistent problem and setting the parity line differently. personal level is limited, if there is mistake, also look correct.
The statements are as follows:
1 --BULK Insert a large number of data statements into a table (odd and even different)2 3 --determine if the test table exists, then delete and then create4 if exists(Select 1 fromsysobjectswhereXtype='u' andName='table_test' )5 Drop Tabletable_test6 Create TableTable_test (7Idint,8NameChar( -),9AddressChar( -),TenGenderChar(Ten) One ) A - Declare @n int - Declare @name varchar( -)--Using Variables the Declare @name1 varchar( -)--set odd for - Declare @name2 varchar( -)--Set even numbers - Declare @addre varchar( -)--Using Variables - Declare @sql varchar( $) + Set @n=0 - Set @addre=''s Home' + Set @name=' ' A Set @name1='Tom' at Set @name2='Jarry' - while @n<998--do not 2999, nor 1999, as long as 998, yes, as long as 998 - begin - Set @n=@n+1 - if @n%2=1--Odd Rows - begin in Set @name=@name1+Convert(varchar,@n)--combination of name and number to avoid duplicate Name column - Set @addre=@name+@addre--address by the name of the "home" combination to avoid different to Set @sql='INSERT INTO Table_test (Id,name,address,gender) VALUES ('+Convert(int,@n)+','+@name+','+@addre+',"'male"')' + Set @addre=''s Home'--because @address has already assigned a new value, manually restore the initial value, avoid duplicate assignment cause the word descriptor long - Print(@sql) the exec(@sql) * End $ Else--even rowsPanax Notoginseng begin - Set @name=@name2+Convert(varchar,@n) the Set @addre=@name+@addre + Set @sql='INSERT INTO Table_test (Id,name,address,gender) VALUES ('+Convert(int,@n)+','+@name+','+@addre+',"'female"')' A Set @addre=''s Home' the Print(@sql) + exec(@sql) - End $ End
This allows you to bulk insert multiple rows into the table as required.
I tried inserting 18750000 rows myself.
Nice
SQL Server inserts multi-line data statements into a table in bulk