sql server 字符串分割函数(split),支持中文,支持长分割符
来源:互联网 发布:女生网络钓鱼 编辑:程序博客网 时间:2024/06/05 16:08
-- =============================================-- Author: 爱因光-- Create date: 2012年2月12日-- Description: 字符串分割函数,支持长分割符,支持中文-- =============================================CREATE FUNCTION [dbo].[split](@Long_str varchar(8000),@split_str varchar(100)) RETURNS @tmp TABLE( [myid] int IDENTITY PRIMARY KEY, [mystr] varchar(8000) ) AS BEGIN DECLARE @long_str_Tmp varchar(8000), @short_str varchar(8000), @split_str_length int SET @split_str_length = LEN(@split_str) IF CHARINDEX(@split_str,@Long_str)=1 SET @long_str_Tmp=SUBSTRING(@Long_str, @split_str_length+1, LEN(@Long_str)-@split_str_length) ELSE SET @long_str_Tmp=@Long_str IF CHARINDEX(REVERSE(@split_str),REVERSE(@long_str_Tmp))>1 SET @long_str_Tmp=@long_str_Tmp+@split_str ELSE SET @long_str_Tmp=@long_str_Tmp WHILE CHARINDEX(@split_str,@long_str_Tmp)>0 BEGIN SET @short_str=SUBSTRING(@long_str_Tmp,1, CHARINDEX(@split_str,@long_str_Tmp)-1) DECLARE @long_str_Tmp_LEN INT,@split_str_Position_END int SET @long_str_Tmp_LEN = LEN(@long_str_Tmp) SET @split_str_Position_END = LEN(@short_str)+@split_str_length SET @long_str_Tmp=REVERSE(SUBSTRING(REVERSE(@long_str_Tmp),1, @long_str_Tmp_LEN-@split_str_Position_END)) IF @short_str<>'' INSERT INTO @tmp SELECT @short_str END RETURN END
转自 http://www.cnblogs.com/weblogical/archive/2011/03/03/1969798.html
我稍微改动了一下
- sql server 字符串分割函数(split),支持中文,支持长分割符
- SQL 字符串分割函数 split
- SQL Server里用Split函数分割字符串
- Mysql实现split函数——支持多字符分割
- sql 分割字符串split
- sql server 自定义split(分割)函数
- split字符串分割函数
- split函数分割字符串
- php如何分割字符串?php mb_substr分割字条串,解决中文乱码问题,支持分割中文!
- 分割字符串函数split(C#)
- 分割字符串函数split(C#)
- c 分割字符串函数 split
- oracle字符串分割函数split
- php 字符串分割函数split
- Java-split函数-分割字符串
- 黑马程序员--SQL Server 中实现类似Split的字符串分割函数
- SQL Server字符串分割
- SQL SERVER分割字符串
- Linux进程运行空间查看
- 学习SQL语言----1
- Maven+Eclipse+Spring MVC简单实例(很详细透彻的文档,手把手教会你)
- poj3013
- Android中构建HTML5应用
- sql server 字符串分割函数(split),支持中文,支持长分割符
- win7家庭普通版无法卸载vmware的解决方法之一
- 《C语言接口与实现》实验——格式化(Fmt_T)
- python spark
- python os模块
- 解决 svn: This client is too old to work with working copy 问题
- WebGL带来的改变
- sk_buff结构
- 线程介绍