sqlserver实现分隔字符串
sqlserver 使用函数实现分隔字符串
createfunction dbo.fn_split(
@str_sourcenvarchar(max),@split_charnvarchar(100))
returns@temptable(
id
intprimarykeyidentity(1,1),val
varchar(max))
asbegin
declare@idxint,@split_lenint
set@str_source=rtrim(ltrim(@str_source))
set@idx=charindex(@split_char,@str_source)
set@split_len=len(@split_char)
while(@idx>0)
begin
insertinto@tempvalues(left(@str_source,@idx-1))
set@idx+=@split_len-1
set@str_source=substring(@str_source,@idx+1,len(@str_source)-@idx)
set@idx=charindex(@split_char,@str_source)
end
if(@str_source!="")
begin
insertinto@tempvalues(@str_source)
end
return
end
以上是 sqlserver实现分隔字符串 的全部内容, 来源链接: utcz.com/z/531446.html