• 字符串分隔(转自别处)


    CREATE FUNCTION [dbo].[GetSplitOfIndex]
    (
          @String NVARCHAR(MAX) ,  --要分割的字符串
          @split NVARCHAR(10) ,  --分隔符号
          @index INT --取第几个元素
    )
    RETURNS NVARCHAR(1024)
    AS
        BEGIN
            DECLARE @location INT
            DECLARE @start INT
            DECLARE @next INT
            DECLARE @seed INT
     
            SET @String = LTRIM(RTRIM(@String))
            SET @start = 1
            SET @next = 1
            SET @seed = LEN(@split)
     
            SET @location = CHARINDEX(@split, @String)
            WHILE @location <> 0
                AND @index > @next
                BEGIN
                    SET @start = @location + @seed
                    SET @location = CHARINDEX(@split, @String, @start)
                    SET @next = @next + 1
                END
            IF @location = 0
                SELECT  @location = LEN(@String) + 1
     
            RETURN SUBSTRING(@String,@start,@location-@start)
        END

  • 相关阅读:
    jQuery入门级part.2
    jQuery入门级part.1
    总结十二天
    延时器和定时器
    总结第十一天
    总结第十天
    总结第九天
    android特殊字符
    android 查看 当前activity
    京东运营 不错的帖子
  • 原文地址:https://www.cnblogs.com/zhang9418hn/p/2299214.html
Copyright © 2020-2023  润新知