我真的不知道该这么办了。
declare @i int
set @i=0
while @i<=100000
begin
if exists (select f1 from t1 where f1=@i)
begin
raise error('重复了',15,2)
return
end
insert into t1(f1,f2) (@i,@i*2)
set @i=@i+1
end
类试这样的一段代码,要在数据库中插入记录,运行了30分钟。
大侠请出手,帮我想想办法吧。
---------------------------------------------------------------
select n = identity(int,1,1)
into #a
from (select top 100 a=1 from syscolumns) as a,
(select top 100 a=1 from syscolumns) as b,
(select top 10 a=1 from syscolumns) as c
insert into t1(f1,f2)
select n,n*2 from #a
where n not in(select f1 from t1)