在SQL 数据库中,有一张表里面有,ID,name,address,age,bitrday列,现在要求一个存储过程,一次插入100000条数据,求各位大侠帮助!小弟感激不尽。
if OBJECT_ID('person') is not null
drop table person
go
create table person
(
[id] int identity(1,1) not null,
[Name] nvarchar(20) ,
[Address] nvarchar(50) ,
[age] int,
[bitrday] datetime)
go
declare @name varchar(20)
declare @age int
declare @mb varchar(50)
declare @count int
set @count = 0
--插入10万条随机的记录
while(@count < 100000)
begin
--生成随机的PID
select @name=substring(cast(rand() as varchar(20)),3,6)+
substring(cast(rand() as varchar(20)),3,6)+substring(cast(rand() as varchar(20)),3,6)
--生成随机的MB
select @mb=substring(cast(rand() as varchar(20)),3,6)+
substring(cast(rand() as varchar(20)),3,5)
--生成随机的AGE
select @age = cast (rand() * 100 as int)
--将生成的随机数据插入表
insert into person
values ( @name, @mb,@age,dateadd(yy,0-@age,getdate()))
set @count = @count + 1
end