sql带分隔符的截取字符串示例
时间:2024-01-13 04:52:12
eclare @str nvarchar(50);
set @str='462,464,2';
select @str as '字符串'
select len(@str) as '字符长度'
select charindex(',',@str,1) as '第一个逗号的索引值'
select LEFT(@str,charindex(',',@str,1)-1) as '第一个值'
select SUBSTRING(@str,charindex(',',@str,1)+1,len(@str)) as '从第一逗号开始截取出后面的字符串'
select LEFT(SUBSTRING(@str,charindex(',',@str,1)+1,len(@str)),CHARINDEX(',',SUBSTRING(@str,charindex(',',@str,1)+1,len(@str)),1)-1) as '中间的值'
select SUBSTRING(SUBSTRING(@str,charindex(',',@str,1)+1,len(@str)),charindex(',',SUBSTRING(@str,charindex(',',@str,1)+1,len(@str)),1)+1,len(@str)) as '最后面的值' --从第二个逗号开始截取出其后的字符串
标签:sql,字符串,分隔符
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
10分钟带你上手Vue3中新增的API
2024-06-05 10:03:00
python3爬取torrent种子链接实例
2022-03-05 11:23:44
![](https://img.aspxhome.com/file/2023/2/99162_0s.jpg)
HTML中使背景图片自适应浏览器大小实例详解
2024-05-02 16:18:32
Python 自动补全(vim)
2021-11-06 16:54:42
![](https://img.aspxhome.com/file/2023/4/93774_0s.jpg)
JS统计Flash被网友点击过的代码
2024-05-03 15:06:18
Google的用户体验设计原则
2009-01-12 18:31:00
讲解数据库管理系统必须提供的基本服务
2009-01-04 14:33:00
Python实现爆破ZIP文件(支持纯数字,数字+字母,密码本)
2021-09-01 22:30:12
![](https://img.aspxhome.com/file/2023/5/135245_0s.png)
在Python开发环境中调用ChatGPT模型详细过程
2022-03-25 21:59:29
![](https://img.aspxhome.com/file/2023/3/97603_0s.jpg)
如何在Linux 系统中使用apt 包管理器安装 Git LFS
2022-08-29 15:33:30
Python包装之对象处理
2022-10-15 07:01:33
![](https://img.aspxhome.com/file/2023/1/100931_0s.jpg)
使用VS2005调试ASP程序方法
2007-11-02 09:56:00
![](https://img.aspxhome.com/file/UploadPic/200711/2/200711210317494s.jpg)
注册和填表中常见的中英文对照
2008-07-26 12:12:00
sql数据库修改sa密码操作教程
2023-07-09 19:35:52
Win10下python3.5和python2.7环境变量配置教程
2021-08-31 10:40:23
![](https://img.aspxhome.com/file/2023/3/80623_0s.png)
JavaScript实现简易购物车最全代码解析(ES6面向对象)
2024-04-16 10:40:11
![](https://img.aspxhome.com/file/2023/6/136566_0s.gif)
javascript中caller和callee详解
2024-04-29 13:38:05
PHP访问MySQL查询超时处理的方法
2023-11-23 03:05:48
![](https://img.aspxhome.com/file/2023/2/85812_0s.jpg)
python程序中调用其他程序的实现
2021-08-07 12:33:16
JavaScript中Infinity(无穷数)的使用和注意事项
2023-08-21 00:59:13