首页 > 代码库 > SQL SERVER 2008 R2 插入数据非常慢

SQL SERVER 2008 R2 插入数据非常慢

表是5字段int类型,第一个字段是主健,自增字段

表结构:

id int  Unchecked
billno bigint  Unchecked
opid int  Checked
billopid int  Checked
tag int  Checked

 

存储过程:

CREATE proc [dbo].[inbill]
@bills bigint,
@bille bigint,
@billopid int,
@result int output,
@incount int output
as
begin
  set @result = (select COUNT(*) from bill where billno >= @bills and billno<=@bille)
  set @incount = 0
  if @result = 0 
  begin
    while @bills + @incount <= @bille 
    begin
      insert into bill (billno,billopid) values (@bills + @incount,@billopid)
      set @incount = @incount + 1
    end
  end
end

SQL SERVER 2008 R2 插入数据非常慢