sql分割字符串函数

 时间:2024-10-13 05:00:41

1、char坡纠课柩index内置函数返回指定字符所出现的位置。第一个参数为目标字符串,即查找的字符串;第二个参数为被查找的字符串;第三个参数为开始查找位置,为空时默认从第一位查找

sql分割字符串函数sql分割字符串函数

3、测试函数。

sql分割字符串函数

4、函数脚本;create function [dbo].[fn_Split](@str varchar(max), --原字符串刺胳挤萧@fgzf varchar(10) --分割符号)returns @table table --返回(id int identity(1,1),value varchar(max))asbegindeclare @len int = 1;declare @len1 int = 1;declare @count int = 0;set @count = len(@str);if(@count > 0)begin while @len <> 0 begin set @len1 = @len;if(@len = 1) begin set @len = CHARINDEX(@fgzf,@str,@len);end else begin set @len = CHARINDEX(@fgzf,@str,@len + 1);end if(@len1 = 1)begin if(@len <> 0)begin insert into @table(value)select SUBSTRING(@str,@len1,@len-1);endelse begin insert into @table(value)select @str;end endelse if (@len <> 0) begin insert into @table(value)select SUBSTRING(@str,@len1 + 1,@len - @len1 -1);end if(@len = 0 and @len1 > 1) begin insert into @table(value)select SUBSTRING(@str,@len1 + 1,len(@str) - @len1);end end endreturn;end

  • insert into语句怎么用
  • 清空表数据sql
  • linux查找文件中的关键字
  • js如何截取某个字符前面所有的字符串
  • Dynamic Performance Tables not accessible
  • 热门搜索
    旅游票务 黄山旅游图 北京旅游风景区 海南自助旅游 温州旅游团 湖北旅游局 旅游seo 阆中古城旅游攻略 深圳免费旅游景点大全 旅游知识