当前位置: 数据库>sqlserver
sqlserver 字符串分拆 语句
来源: 互联网 发布时间:2014-09-05
本文导语: 代码如下:-->Title:生成測試數據 -->Author:wufeng4552 -->Date :2009-09-21 09:02:08 if object_id('f_split')is not null drop function f_split go create function f_split ( @s varchar(8000), --待分拆的字符串 @split varchar(10) --数据分隔符 )returns table as return ( select substri...
代码如下:
-->Title:生成測試數據
-->Author:wufeng4552
-->Date :2009-09-21 09:02:08
if object_id('f_split')is not null drop function f_split
go
create function f_split
(
@s varchar(8000), --待分拆的字符串
@split varchar(10) --数据分隔符
)returns table
as
return
(
select substring(@s,number,charindex(@split,@s+@split,number)-number)as col
from master..spt_values
where type='p' and number