|
SQL 中自己创建函数,分割字符串(5) --返回数组的个数
CREATE function getstrcount (@str varchar(8000),@splitstr varchar(100)) --returns varchar(8000) returns int as begin declare @int_return int declare @start int declare @next int declare @location int select @next = 0 select @location = 1 if len(@str)<len(@splitstr) select @int_return =0 if charindex(@splitstr,@str) = 0 select @int_return =0 while (@location<>0) begin select @start = @location + 1 select @location = charindex(@splitstr,@str,@start) select @next = @next + 1 select @int_return = @next end return @int_return
|