日期:2014-05-18 浏览次数:20591 次
alter function division (@strFieldValue varchar(1000),@spChar varchar(10)) returns @tb table (id int,member varchar(40)) as begin declare @strTask_id int declare @intTimes int select @strTask_id = (select task_id from Tid where members = @strFieldValue) select @intTimes = charindex(',',@strFieldValue) while(@intTimes>=0) begin if(@intTimes >0) begin select @strFieldValue = substring(@strFieldValue,charindex(',',@strFieldValue)+1, len(@strFieldValue)) insert @tb select @strTask_id,@strFieldValue select @intTimes = charindex(',',@strFieldValue) end else begin insert @tb select @strTask_id,@strFieldValue select @intTimes = -1 end end return end