Home > Database > Mysql Tutorial > sqlserver 字符串分拆 语句

sqlserver 字符串分拆 语句

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-07 17:59:26
Original
898 people have browsed it

sqlserver下字符串分拆实现语句,大家可以参考下。

代码如下:
-->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 numberand charindex(@split,@split+@s,number)=number
)
go
select * from dbo.f_split('11,2,3',',')

/*
col
----
11
2
3
(3 個資料列受到影響)
*/
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
Problem with tp6 connecting to sqlserver database
From 1970-01-01 08:00:00
0
0
0
Unable to connect to SQL Server in Laravel
From 1970-01-01 08:00:00
0
0
0
Methods of parsing MYD, MYI, and FRM files
From 1970-01-01 08:00:00
0
0
0
SQLSTATE: User login failed
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template