执行如下存储过程:
declare @scp_code varchar(50);declare @id INT;DECLARE cur CURSOR FOR --查找s_link 有反复的门路select cp_code from cp_sickGROUP BY cp_code, s_link HAVING count(s_link) > 1;OPEN cur fetch next from cur into @scp_codewhile(@@fetch_status=0)beginprint(@scp_code)set @id=0update cp_sick SET s_link=@id,@id=@id+1 WHERE cp_code = @scp_code;fetch next from cur into @scp_codeend close cur DEALLOCATE cur