USE [test]
GO
/****** Object: UserDefinedFunction [dbo].[tf_split_char] Script Date: 2019/7/8 14:39:15 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER FUNCTION [dbo].[tf_split_char]
(
@cstring NVARCHAR(MAX), --被拆分的字符串
@csplit NVARCHAR(1) --分隔符
)
RETURNS @t TABLE
(
id INT IDENTITY(1, 1) PRIMARY KEY,
cchar NVARCHAR(MAX) NOT NULL
)
AS
BEGIN
DECLARE @ilocation INT = 0;
DECLARE @inextlocation INT = 1;
DECLARE @ilen INT;
WHILE @inextlocation > 0
BEGIN
SET @inextlocation = CHARINDEX(@csplit, @cstring, @ilocation + 1);
SET @ilen = CASE
WHEN @inextlocation > 0 THEN
@inextlocation
ELSE
LEN(@cstring) + 1
END - @ilocation - 1;
INSERT INTO @t
(
cchar
)
VALUES
(SUBSTRING(@cstring, @ilocation + 1, @ilen));
SET @ilocation = @inextlocation;
END;
RETURN;
END;

最新文章

  1. 在 C# 中执行 msi 安装
  2. DataSet, BindingSource, BindingNavigator Relationship
  3. GDI学习之俄罗斯方块续
  4. Jalopy 之 HelloWorld —— Jalopy 在 MyEclipse 下的安装与使用
  5. html笔记——网页中视频播放,文字滚动
  6. NpoiUtil
  7. Android设置虚线、圆角、渐变
  8. 办理卡尔加里大学(本科)学历认证『微信171922772』calgary学位证成绩单使馆认证University of calgary
  9. 2-SAT算法
  10. datatable的部分问题处理(动态定义列头,给某行添加事件,初始显示空数据)
  11. ECMA Script 6_行为重定义 Proxy
  12. Day 3-6 生成器&迭代器
  13. js 中常用的循环
  14. golang: 利用unsafe操作未导出变量
  15. uoj #14.【UER #1】DZY Loves Graph
  16. 无线linux应用及配置--wifi配置
  17. P2322 [HNOI2006]最短母串问题
  18. 《转》python学习(6)序列类型-字符串
  19. mysql 数据操作 单表查询 where约束 like 模糊匹配
  20. ERROR 1130 (HY000): Host '192.168.0.190' is not allowed to connect to this MySQL serv

热门文章

  1. Qbxt 模拟题 day3(am) T3 选数字 (select)(贪心)
  2. 推荐系统系列(四):PNN理论与实践
  3. Marcin and Training Camp
  4. [题解] [HNOI2014] 世界树
  5. IDEA下载安装及绿色方法
  6. JDBC——数据库连接池以及JDBC代码模版模版
  7. 删除github上的一个repository
  8. vue 登录页面填坑
  9. vue路由在keep-alive下的刷新问题 对watch的影响
  10. phpstrom--------config php interpreter