zoukankan      html  css  js  c++  java
  • [原创]把","号分隔的字串转化成一列的Table

    alter function dbo.ufn_ConvertToIntList
    (
     
    @data varchar(7990)
    )
    returns @table Table(c int not null)
    as
    begin
        
    declare @str varchar(8000),@iter varchar(50)
                ,
    @beginPos int@endPos int
        
    select @str= @data + ','@beginPos = 1@endPos = charindex(','@str@beginPos)
        
    while(@endPos > 0)
        
    begin
            
    set @iter = SubString(@str,@beginPos ,@endPos - @beginPos )
            
    if(@iter <> '')
            
    begin 
                
    insert into @table(c) values(Convert(int,@iter))
            
    end
            
    select @beginPos =  @endPos + 1@endPos = charindex(','@str@beginPos)
        
    end
        
    return
    end
    go

    declare @data varchar(8000)
            ,
    @i int
        
    select @i = 1@data ='1,2,3,4,5,6,7,8,9,2,3,4,5,6,7,8,9,2,3,4,5,6,7,8,9,2,3,4,5,6,7,8,9,2,3,4,5,6,7,8,9,2,3,4,5,6,7,8,9,2,3,4,5,6,7,8,9,2,3,4,5,6,7,8,9,2,3,4,5,6,7,8,9,2,3,4,5,6,7,8,9,2,3,4,5,6,7,8,9,2,3,4,5,6,7,8,9,2,3,4,5,6,7,8,9,2,3,4,5,6,7,8,9,2,3,4,5,6,7,8,9,2,3,4,5,6,7,8,9,2,3,4,5,6,7,8,9,2,3,4,5,6,7,8,9,2,3,4,5,6,7,8,9,2,3,4,5,6,7,8,9,2,3,4,5,6,7,8,9,2,3,4,5,6,7,8,9,2,3,4,5,6,7,8,9,2,3,4,5,6,7,8,9,2,3,4,5,6,7,8,9,2,3,4,5,6,7,8,9,2,3,4,5,6,7,8,9,2,3,4,5,6,7,8,9,2,3,4,5,6,7,8,9,2,3,4,5,6,7,8,9'
    while(@i < 20)
    begin
        
    select * from dbo.ufn_ConvertToIntList(@data)
        
    set @i= @i +1
    end
    QQ:273352165 evlon#126.com 转载请注明出处。
  • 相关阅读:
    CAS 之 集成RESTful API
    RSA客户端js加密服务器C#解密(含源码)
    Java实现文件的RSA和DES加密算法
    对称加密DES和TripleDES
    VCL消息处理机制
    10款你应该了解的开源安全工具
    一个登陆框引起的血案
    npm install -S -D -g 有什么区别
    共享软件中恶意代码插入技术研究
    GyoiThon:基于机器学习的渗透测试工具
  • 原文地址:https://www.cnblogs.com/evlon/p/386580.html
Copyright © 2011-2022 走看看