if exists (select * from sysobjects where id = object_id('dbo.clkcyg') and sysstat & 0xf = 4)
drop procedure dbo.clkcyg
GO
CREATE PROCEDURE clkcyg AS
declare @xkbh char(4)
declare @kcdm char(7)
declare @jxbh int
declare @yxlb varchar(55)
declare @nj char(4)
declare @nj1 char(4)
declare @rs int
declare @yzbz tinyint
declare @x varchar(2)
declare @yxlb1 varchar(16)
declare @yxlb2 varchar(50)
declare @ws char(2)
declare @bj int
declare cs1 SCROLL cursor for
select xkbh,kcdm,jxbh,yxlb,nj,rs,x from kcyg order by xkbh
open cs1
truncate table kb_yz
fetch next from cs1 into @xkbh,@kcdm,@jxbh,@yxlb,@nj,@rs,@x
while @@FETCH_STATUS<>-1
begin
if @x='选'
select @yzbz=0
else
select @yzbz=1
select @nj1=ltrim(rtrim(@nj))
select @bj=NULL
......(省略了一些判断语句)
insert into kb_yz (xkbh,kcdm,jxbh,yxlb,nj,rs,x,yzbz,bh) values(@xkbh,@kcdm,@jxbh,@yxlb1,@nj1,@rs,@x,@yzbz,@bj)
fetch next from cs1 into @xkbh,@kcdm,@jxbh,@yxlb,@nj,@rs,@x
end
close cs1
DEALLOCATE cs1
GO