SQL实用技巧:如何分割字符串
作者:互联网
create function f_split(@c varchar(2000),@split varchar(2))
returns @t table(col varchar(20))
as
begin
while(charindex(@split,@c)<>0)
begin
insert @t(col) values (substring(@c,1,charindex(@split,@c)-1))
set @c = stuff(@c,1,charindex(@split,@c),'')
end
insert @t(col) values (@c)
return
end
go
select * from dbo.f_split('dfkd,dfdkdf,dfdkf,dffjk',',')
drop function f_split
标签:function,实用技巧,begin,varchar,charindex,split,SQL,字符串,col 来源: https://www.cnblogs.com/chenshc/p/11827685.html