IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID('[dbo].[sys_sql_genbatchid]') AND type = 'P')
DROP PROCEDURE [dbo].[sys_sql_genbatchid]
GO
--生成批次
create procedure [dbo].[sys_sql_genbatchid](
@parseid int
)
as
begin
declare @batchid int,@condname varchar(200)
set @batchid=1

Declare curs Cursor static local For
select distinct condname
from sys_sql_fld
where parseid=@parseid and isforupdate=1
open curs

fetch next from curs into @condname
while (@@FETCH_STATUS=0)
begin
update sys_sql_fld
set batchid=@batchid
where parseid=@parseid and isforupdate=1 and condname=@condname

fetch next from curs into @condname
select @batchid=@batchid+1
end
end