sqlserver分割字符串,创建临时表

create   function   [dbo].[f_split](@c   varchar(max),@split   varchar(2))   
returns   @t   table(col   varchar(max))   
as   
    begin     
      while(charindex(@split,@c)<>0)   
        begin   
          insert    @t
                    ( col
                    )
          VALUES    ( SUBSTRING(@c, 1, charindex(@split, @c) - 1)
                    )   
          set   @c   =   stuff(@c,1,charindex(@split,@c),'')   
        end   
      insert   @t(col)   values   (@c)   
      return   
    end

posted on 2020-03-01 22:23  hyoukei  阅读(281)  评论(0)    收藏  举报

导航