Sybase:TSQL按逗号分隔字符串[注:无实际用处]

DECLARE @subSql varchar(8000), @strType varchar(50),@type varchar(8), @i1 INT@i2 INT
set @subSql=''
set @strType=',3,4,5,7,8,9,10,11,22,23,25,40,41,45,46,'
set @i1=charindex(',',@strType)
set @strType = substring(@strType,@i1+1,50)
set @i2=charindex(',',@strType)
set @type = substring(@strType,@i1,@i2-1)
set @strType = substring(@strType,@i2,50)
print @type
WHILE @i2>1
begin
    
set @subSql=@subSql+' OOP-- '+ @type     
    
set @i1=charindex(',',@strType)
    
set @strType = substring(@strType,@i1+1,50)   
    
set @i2=charindex(',',@strType)
    
set @type = substring(@strType,@i1,@i2-1)   
    
set @strType = substring(@strType,@i2,50)   
    
print @type 
end
print @subSql
原文地址:https://www.cnblogs.com/ding0910/p/1210854.html