zoukankan      html  css  js  c++  java
  • 此函数实现sql中的字段中字符串的split方法

    create FUNCTION [dbo].[SplitToTable]
    (
          @SplitString nvarchar(max),
          @Separator nvarchar(10)=' '
      )
      RETURNS @SplitStringsTable TABLE
      (
      [id] int identity(1,1),
      [value] nvarchar(max)
     )
     AS
     BEGIN
         DECLARE @CurrentIndex int;
         DECLARE @NextIndex int;
         DECLARE @ReturnText nvarchar(max);
         SELECT @CurrentIndex=1;
         WHILE(@CurrentIndex<=len(@SplitString))
             BEGIN
                 SELECT @NextIndex=charindex(@Separator,@SplitString,@CurrentIndex);
                 IF(@NextIndex=0 OR @NextIndex IS NULL)
                     SELECT @NextIndex=len(@SplitString)+1;
                     SELECT @ReturnText=substring(@SplitString,@CurrentIndex,@NextIndex-@CurrentIndex);
                     INSERT INTO @SplitStringsTable([value]) VALUES(@ReturnText);
                     SELECT @CurrentIndex=@NextIndex+1;
                 END
         RETURN;
     END

  • 相关阅读:
    项目Beta冲刺(团队) --1/7
    Beta:凡事预则立
    事后诸葛亮(葫芦娃队)
    项目问题回复
    Alpha冲刺阶段总结
    Alpha冲刺笔记十:第十天
    Alpha冲刺随笔九:第九天
    项目测试用例
    Alpha冲刺随笔八:第八天
    项目Beta冲刺(团队2/7)
  • 原文地址:https://www.cnblogs.com/TNSSTAR/p/2701088.html
Copyright © 2011-2022 走看看