SQL Server ???????????????
???????????? ???????[ 2015/5/29 14:03:16 ] ?????????????
???????????????????????????????????????????????????????????д????????????????????????????????????????????
1 create function Func_StrArrayLength
2 (
3 @str varchar(1024)?? --??????????
4 @split varchar(10) --??????
5 )
6 returns int
7 as
8 begin
9 declare @location int
10 declare @start int
11 declare @length int
12
13 set @str=ltrim(rtrim(@str))
14 set @location=charindex(@split??@str)
15 set @length=1
16 while @location<>0
17 begin
18 set @start=@location+1
19 set @location=charindex(@split??@str??@start)
20 set @length=@length+1
21 end
22 return @length
23 end
24 go
?????????????select dbo.Func_StrArrayLength('78??1??2??3'??'??')
???????????4
??????????????????????????????????????????????????????????????????????????
1 create function Func_StrArrayStrOfIndex
2 (
3 @str varchar(1024)?? --??????????
4 @split varchar(10)?? --??????
5 @index int --?????????
6 )
7 returns varchar(1024)
8 as
9 begin
10 declare @location int
11 declare @start int
12 declare @next int
13 declare @seed int
14
15 set @str=ltrim(rtrim(@str))
16 set @start=1
17 set @next=1
18 set @seed=len(@split)
19
20 set @location=charindex(@split??@str)
21 while @location<>0 and @index>@next
22 begin
23 set @start=@location+@seed
24 set @location=charindex(@split??@str??@start)
25 set @next=@next+1
26 end
27 if @location =0 select @location =len(@str)+1
28 --??????????????????????????????????2????????д?????????????while?????@location?????????????????????????????
29
30 return substring(@str??@start??@location-@start)
31 end
32 go
?????????????select dbo.Func_StrArrayStrOfIndex('8??9??4'??'??'??2)
???????????9
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11