因为不想再程序中写循环,因此把UI页面需要更新的纪录的主键组成了一个以","隔开的字符串,将这个字符串传入存储过程中进行处理
CREATE PROCEDURE UpdateGroupIDOfSelContant @SelContant varchar(255), @GroupID int AS if len(@SelContant)> 0 BEGIN declare @i int set @i=charindex(',',@SelContant) while @i>=1 begin update T_txl_contant set GroupID = @GroupID where ContID = left(@SelContant,@i-1) set @SelContant=substring(@SelContant,@i+1,len(@SelContant)-@i) set @i=charindex(',',@SelContant) end if @SelContant<>'\' update T_txl_contant set GroupID = @GroupID where ContID =@SelContant END |