SQL stored procedure, copy array

Source: Internet
Author: User
Tags rtrim

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.