存储过程之处理多笔拼接字符串数据

存储过程之处理多笔拼接字符串


CREATE
proc [dbo].[pro_Update] @Models nvarchar(4000) as declare @id varchar(500),@m int,@n int,@mm int,@nn int,@jobId nvarchar(10),@true nvarchar(10) declare @classId varchar(50),@jobName varchar(100),@shenfen varchar(100) set @m=CHARINDEX('-',@Models) set @n=1 WHILE @m>0 BEGIN set @id=substring(@Models,@n,@m-@n) begin set @mm=CharIndex(',',@id) set @nn=1 set @jobId=substring(@id,@nn,@mm-@nn) set @nn=@mm+1 set @mm=Charindex(',',@id,@nn) set @true=substring(@id,@nn,@mm-@nn) set @nn=@mm+1 set @mm=Charindex(',',@id,@nn) set @shenfen=substring(@id,@nn,@mm-@nn) set @nn=@mm+1 set @mm=Charindex(',',@id,@nn) set @classId= substring(@id,@nn,@mm-@nn) set @nn=@mm+1 set @mm=Charindex(',',@id,@nn) set @jobName=substring(@id,@nn,@mm-@nn) update jobs set IsBuKao=@true where JobID=convert(int,@jobId) if(@true='false') begin update jobs set BuKaoCount=BuKaoCount-1 where jobId=convert(int,@jobId) end else if(@true='true') begin update jobs set BuKaoCount=BuKaoCount+1 where jobID=convert(int,@jobId) end end set @n=@m+1 set @m=CHARINDEX('-',@Models,@n) END

 

posted @ 2012-12-06 09:43  望月狼  阅读(662)  评论(0编辑  收藏  举报