sql每五秒插入一条数据 一次插入N条数据

1建立数据表

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 projectManage

insert projectManage values('装机','小明','大明','工程监理','','1990-9-9','2000-9-9','13527748096','13527748096','13527748096','13527748096','13527748096','13527748096')
View Code

 

2利用while循环每五秒插入一条数据
declare @dt datetime,@today datetime,@a varchar(max),@z datetime set @a=0

select @today=CONVERT(varchar(100), GETDATE(), 20),@dt=@today

while @a<1

begin

select @today=CONVERT(varchar(100), GETDATE(), 20)



   while @dt=@today

   begin

   insert projectManage values('装机bb'+@a,'小明','大明','工程监理','',@dt,'2000-9-9','13527748096','13527748096','13527748096','13527748096','13527748096','13527748096')

    set @dt=DATEADD(SECOND,5,@dt)

   end

set @a=@a-1

end
View Code

3一次插入N条数据

declare @i varchar(max)

set @i=1

while 

@i<1000001

begin

insert projectManage values('装机'+@i,'小明','大明','工程监理','','1990-9-9','2000-9-9','13527748096','13527748096','13527748096','13527748096','13527748096','13527748096')

 

set @i=@i+1

end
View Code

 

你可能感兴趣的:(sql)