create FUNCTION [dbo].[dnt_split]
(
@splitstring varchar(max),
@separator CHAR() = ','
)
RETURNS @splitstringstable TABLE
(
[item] VARCHAR()
)
AS
BEGIN
DECLARE @currentindex INT
DECLARE @nextindex INT
DECLARE @returntext VARCHAR() SELECT @currentindex= WHILE(@currentindex<=datalength(@splitstring))
BEGIN
SELECT @nextindex=charindex(@separator,@splitstring,@currentindex)
IF(@nextindex= OR @nextindex IS NULL)
SELECT @nextindex=datalength(@splitstring)+ SELECT @returntext=substring(@splitstring,@currentindex,@nextindex-@currentindex) INSERT INTO @splitstringstable([item])
VALUES(@returntext) SELECT @currentindex=@nextindex+
END
RETURN
END

调用方法:

select * from dbo.dnt_split('123,123',',')

sql server split切割字符串的更多相关文章

  1. SQL Server中截取字符串常用函数

    SQL Server 中截取字符串常用的函数: .LEFT ( character_expression , integer_expression ) 函数说明:LEFT ( '源字符串' , '要截 ...

  2. sql server 查找包含字符串的对象

    sql server 查找包含字符串的对象 SELECT sm.object_id, OBJECT_NAME(sm.object_id) AS object_name, o.type, o.type_ ...

  3. SQL Server 中截取字符串常用的函数

    SQL Server 中截取字符串常用的函数: 1.LEFT ( character_expression , integer_expression ) 函数说明:LEFT ( '源字符串' , '要 ...

  4. golang学习笔记15 golang用strings.Split切割字符串

    golang用strings.Split切割字符串 kv := strings.Split(authString, " ") if len(kv) != 2 || kv[0] != ...

  5. sql server中截取字符串的常用函数

    我们如果要在sql server中,使用截取字符串的方法要怎样使用呢? sql server提供了3个常用截取字符串方法,LEFT().RIGHT().SUBSTRING() /****** Sql ...

  6. Sql Server系列:字符串函数

    字符串函数用于对字符和二进制字符串进行各种操作,大多数字符串函数只能作用于char.nchar.varchar和nvarchar数据类型.字符串函数可以用在SELECT或者WHERE语句中. 1. A ...

  7. SQL Server 2008连接字符串写法大全

    一..NET Framework Data Provider for SQL Server 类型:.NET Framework类库使用:System.Data.SqlClient.SqlConnect ...

  8. SQL Server日期与字符串之间的转换

    本文导读:在SQL Server数据库中,SQL Server日期时间格式转换字符串可以改变SQL Server日期和时间的格式,是每个SQL数据库用户都应该掌握的.下面主要就介绍一下SQL Serv ...

  9. java使用split切割字符串的时候,注意转义字符

    今天在做项目的时候发现一个奇怪的问题 File file = new File("d:\\a.txt"); BufferedReader br = new BufferedRead ...

随机推荐

  1. MD5Encrypt加密

    package utils; import java.security.MessageDigest; public class MD5Encrypt { public MD5Encrypt() { } ...

  2. Python初级 3 基本数学运算

    一. 四大基本运算操作符 1 加+ print(3 + 2) 2 减- print(3 - 2) 3 乘:* print(3 * 2) 4 除/, // print(3 / 2) print(3 // ...

  3. 报错:Error starting Jetty. JSON Metrics may not be available.java.net.BindException:地址已在使用

    报错背景: 刚在CDH中集成Flume插件,启动报错 报错现象: Error starting Jetty. JSON Metrics may not be available. java.net.B ...

  4. Jrebel激活方法(转)

    本次服务长期稳定提供给各位同学使用哦!服务器地址:https://jrebel.qekang.com/{GUID}在线GUID地址:在线生成GUID如果失效刷新GUID替换就可以!打开jrebel 激 ...

  5. LeetCode_392. Is Subsequence

    392. Is Subsequence Easy Given a string s and a string t, check if s is subsequence of t. You may as ...

  6. CompletableFuture Quasar 等并发编程

    CompletableFuture基本用法 https://www.cnblogs.com/cjsblog/p/9267163.html Quasar https://blog.csdn.net/ma ...

  7. 线性回归:boston房价

    from sklearn.linear_model import LinearRegression,Lasso,Ridge from sklearn.datasets import load_bost ...

  8. jquery 单击选中 再次选中取消选中

    html: <div id="full" class='weui-popup__container' style="background: #fff"&g ...

  9. TS - 问题解决力 - 下篇

    本文是已读书籍的内容摘要,少部分有轻微改动,但不影响原文表达. <麦肯锡工作法 - 个人竞争力提升50%的7堂课> ISBN: 9787508644691 https://book.dou ...

  10. jenkins集成robot用例并发送自定义报告

    slave