2013-11-29|1546阅|作者:HANGLV|举报 摘要: SQL Server 分割字符串
create Function Split
(@Sql varchar(8000),@Splits varchar(10))
returns @temp Table (id int identity(1,1),a varchar(100))
As
Begin
Declare @i Int
Set @Sql = RTrim(LTrim(@Sql))
Set @i = CharIndex(@Splits,@Sql)
While @i >= 1
Begin
Insert @temp Values(Left(@Sql,@i-1))
Set @Sql = SubString(@Sql,@i+1,Len(@Sql)-@i)
Set @i = CharIndex(@Splits,@Sql)
End
If @Sql <> ''
Insert @temp Values (@Sql)
Return
End
go