USE [数据库名]
GO
create function [dbo].[f_split]
(
@c varchar(2000),--需要分割的字符串(例如:1,2,3,4,5 我|和|你)
@split varchar(2)--分隔符(例如 , | $)
)
returns @t table(col varchar(200))--返回表
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
标签:分割,varchar,--,begin,Server,charindex,split,SQL,col From: https://www.cnblogs.com/zhaoben/p/17008414.html