侧边栏壁纸
  • 累计撰写 45 篇文章
  • 累计创建 1 个标签
  • 累计收到 1 条评论

目 录CONTENT

文章目录

【043】多语言表字符串处理fn_GetCombineName

绀香廿九
2024-03-13 / 0 评论 / 0 点赞 / 8 阅读 / 994 字
if(OBJECT_ID('fn_GetCombineName') is not null)
drop function fn_GetCombineName
go

CREATE FUNCTION fn_GetCombineName
(
  @CombineName nvarchar(max),
  @SegIndexStr nvarchar(500),
  @SegIndex int
)
RETURNS nvarchar(max)
AS
BEGIN
  
  declare @Result nvarchar(max)=''
  
 declare @SegIndex1 int = 1
 declare @str1 nvarchar(500) = ''
 declare @str2 nvarchar(500) = @CombineName

 while (@SegIndex1 <= @SegIndex)
  begin

  --print(@SegIndex1)

  declare @currentstr nvarchar(500) = ''

  set @currentstr = substring(@str2, 0, CHARINDEX('#@#', @str2, 0))

  declare @Oldstr1 nvarchar(500) = ''

  set @Oldstr1 = @str1

  set @str1 = @str1 + substring(@str2, 0, CHARINDEX('#@#', @str2, 0) + 3)

  set @str2 = substring(@CombineName, len(@str1) + 1, len(@CombineName) - len(@str1))

  if (@SegIndex1 = @SegIndex)
   begin
     set @Result= @Oldstr1 + @SegIndexStr + '#@#' + @str2
  end

 set @SegIndex1 = @SegIndex1 + 1

 end

  return @Result
END
GO
0

评论区