create function split
(@charstring nvarchar(4000), --字串
@separator char(1) --分割符
)returns @tb_temp table (string nvarchar(4000))
asbegin
declare @beginindex int,@separatorindex int,@stringlength int
select @beginindex = 1
select @stringlength = len(@charstring)
while @beginindex <= @stringlength
begin
select @separatorindex = charindex(@separator,@charstring,@beginindex)
declare @v_char nvarchar(4000)
if @separatorindex = 0
select @separatorindex = @stringlength + 1
select @v_char = substring(@charstring,@beginindex,@separatorindex-@beginindex)
insert into @tb_temp values (@v_char)
select @beginindex = @separatorindex + 1
end
return
end
oracle function 分割字串函式
這個函式要用到,記錄下 create or replace function split src varchar2,delimiter varchar2 src 分割的字串,delimiter 分隔符 return t str20list is psrc varchar2 500 a t str20...
Sqlserver 字串分割
字串分割,返回字串按指定分割符分割後長度 使用 select dbo.fun get strarraylength 1,2,3,4 create function dbo fun get strarraylength str varchar 1024 要分割的字串 split varchar 10 ...
SQL SERVER分割字串
1 使用指定的字串分割,返回分割後元素的個數 create function get strlength str varchar 1024 split varchar 10 returns int asbegin declare location int declare start int decl...