1CREATE PROCEDURE Update_erptreelist (@s1 varchar ( +), @s2 varchar ( +))2 as3 Begin4DECLARE @ss1 varchar ( -), @ss2int, @ss2_temp varchar ( -);5DECLARE @ix1int, @ix2int, @pos1int, @pos2int;6 Set@pos1 =1;Set@pos2 =1;Set@ix1 =1;Set@ix2 =1;7 while(@ix1 >0and @ix2 >0)8 Begin9 Set@ix1 =charindex (',', @s1, @pos1);Ten Set@ix2 =charindex (',', @s2, @pos2); One if(@ix1 >0and @ix2 >0) A begin - Set@ss1 =substring (@s1, @pos1, @ix1-@pos1); - Set@ss2_temp =substring (@s2, @pos2, @ix2-@pos2); the Set@ss2 =cast (@ss2_temp as int); -Update [Cspostoa]. [dbo]. [Erptreelist]Set[textstr]=@ss1 - where[id]=@ss2; - End + Else - begin + Set@s1 =substring (@s1, @pos1, LEN (@s1));Set@s2 =SUBSTRING (@s2, @pos2, LEN (@s2)); A End at Set@ss1 =ltrim (RTRIM (@ss1));Set@ss2 =LTRIM (RTRIM (@ss2)); - Set@[email protected]+1;Set@[email protected]+1; - End - End - - Exec update_erptreelist in@s1 ='task management, current tasks, current release tasks, current supervisory tasks, historical tasks, historical release tasks, historical supervision tasks,' -, @s2 ='265,266,267,268,269,270,271,';
SQL stored procedure, copy array