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
------------------------------------------------------------
declare @str varchar(100)
set @str = 'a.bb.ccc'
select * from dbo.f_split(@str,'.')