SQL inserts N data records every five seconds.
1. Create a data table
Create table projectManage (ID int identity primary key not null, projectName nvarchar (20) not null, manager_1 nvarchar (10) not null, manager_2 nvarchar (10) not null, monitor nvarchar (10) not null, isFire varchar (2) null, startTime datetime not null, endTime datetime not null, manager_1tel nvarchar (11) not null, manager_1company nvarchar (20) not null, manager_2tel nvarchar (11) not null, manager_2company nvarchar (20) not null, monitortel nvarchar (11) not null, monitorcompany nvarchar (20) not null) select * from projectManageinsert projectManage values ('installation set', 'xiaoming ', 'daming', 'engineering supervisor ', 'yes', '2017-9-9', '2017-9-9 ', '123', '123', '123', '123', '123', '123 ')View Code
2. Use the while loop to insert a data record every five seconds. declare @ dt datetime, @ today datetime, @ a varchar (max ), @ z datetime set @ a = 0 select @ today = CONVERT (varchar (100), GETDATE (), 20 ), @ dt = @ todaywhile @ a <1 beginselect @ today = CONVERT (varchar (100), GETDATE (), 20) while @ dt = @ today begin insert projectManage values ('installation bb '+ @ a, 'xiaoming', 'daming ', 'engineering supervisor', 'yes', @ dt, '2017-9-9 ', '20170101', '20160301', '20160301', '20160301', '20160301') set @ dt = DATEADD (SECOND, 5, @ dt) endset @ a = @ a-1endView Code
3. Insert N data records at a time
Declare @ I varchar (max) set @ I = 1 while @ I <1000001 begininsert projectManage values ('installation '+ @ I, 'xiaoming', 'daming ', 'engineering supervisor ', 'yes', '1996-9-9', '1996-9-9 ', '1234568', '1234568', '1234568 ', '123', '123') set @ I = @ I + 1endView Code