zoukankan      html  css  js  c++  java
  • sql server 字符串转table

    -- =============================================
    -- Author: gengc
    -- Create date: <2012-12-29> -- Description: <字符串转Table>
    -- Description: <字符串转Table>
    -- SELECT * from dbo.F_StringToTable('123,aaa',',')
    -- =============================================
    create function [dbo].[F_StringToTable] (@str nvarchar(max),@split varchar(10))
    returns @t Table (col varchar(100))
    as
    begin
        declare @i int
        declare @s int
        set @i=1
        set @s=1
        while(@i>0)
        begin    
            set @i=charindex(@split,@str,@s)
            if(@i>0)
            begin
                insert @t(col) values(substring(@str,@s,@i-@s))
            end   
            else begin
                insert @t(col) values(substring(@str,@s,len(@str)-@s+1))
            end
            set @s = @i + 1   
        end
        return
    end

  • 相关阅读:
    前端学习
    python 镜像
    os模块常用操作
    pandas 缺失值与空值处理
    pandas 根据列的值选取所有行
    pandas模块
    编码与解码
    正则表达式
    pthon之字典的遍历
    python作用域
  • 原文地址:https://www.cnblogs.com/chengeng/p/4371633.html
Copyright © 2011-2022 走看看