分割函数
来源:互联网 发布:陈肇雄 聚合数据 编辑:程序博客网 时间:2024/06/05 16:19
CREATE function Get_StrArrayStrOfIndex
(
@str varchar(1024), --要分割的字符串
@split varchar(10), --分隔符号
@index int --取第几个元素
)
returns varchar(1024)
as
begin
declare @location int
declare @start int
declare @next int
declare @seed int
set @str=ltrim(rtrim(@str))
set @start=1
set @next=1
set @seed=len(@split)
set @location=charindex(@split,@str)
while @location<>0 and @index>@next
begin
set @start=@location+@seed
set @location=charindex(@split,@str,@start)
set @next=@next+1
end
if @location =0 select @location =len(@str)+1
return substring(@str,@start,@location-@start)
(
@str varchar(1024), --要分割的字符串
@split varchar(10), --分隔符号
@index int --取第几个元素
)
returns varchar(1024)
as
begin
declare @location int
declare @start int
declare @next int
declare @seed int
set @str=ltrim(rtrim(@str))
set @start=1
set @next=1
set @seed=len(@split)
set @location=charindex(@split,@str)
while @location<>0 and @index>@next
begin
set @start=@location+@seed
set @location=charindex(@split,@str,@start)
set @next=@next+1
end
if @location =0 select @location =len(@str)+1
return substring(@str,@start,@location-@start)
end
select dbo.Get_StrArrayStrOfIndex('会员卡号:90000898',':',1)查询结果:会员卡号
select dbo.Get_StrArrayStrOfIndex('会员卡号:90000898',':',2)查询结果:90000898
阅读全文
0 0
- 分割函数
- 分割函数
- 字符串分割函数SpliteString
- DELPHI字符串分割函数
- strtok函数,分割字符串
- php 分割函数
- Delphi字符串分割函数
- 分割文件名 _splitpath() 函数
- SQL 字符串分割函数
- strtok 字符串分割函数
- 字符串分割函数 strtok
- 字符分割函数.
- 字符串分割函数
- 字符串分割函数
- SQL分割字符串函数
- 分割字符串函数
- 分割函数sql
- [MSSQL]自定义分割函数
- eclipse 快捷键
- easyui-Easyui 中 combobox 绑定2000多条数据 自带检索特别卡 如何优化一下
- 微服务架构的分布式事务解决方案
- dynamic_cast 运算符
- django coverage
- 分割函数
- MAC_McpsDataAlloc的使用
- [简单DP]FatMouse's Speed HDU
- 多层 VUE 循环中,在子循环中拿到父循环的 index
- zookeeper windows 入门安装和测试
- C语言(10)士兵杀敌2
- 使用python-opencv人脸检测,画框,添加字符函数
- Spring Aspectj 代理 前置 后置 以及 异常
- 用Glide加载图片到Recyclerview中有时候只显示占位图的问题