MSSQL字符串分段截取

-->Title:Generating test data

-->Author:wufeng4552

-->Date :2009-09-30 15:16:26

--字符串分段截取

declare @s varchar(50),@split varchar(2),@pos int,@splitlen int

select @s='a,b,ct,d,e,f,g',@split=',',@pos=3,@splitlen=len(@split+'a')-2

while @pos>1 and charindex(@split,@s+@split)>0

select @pos=@pos-1,@s=stuff(@s,1,charindex(@split,@s+@split)+@splitlen,'')

select left(@s,charindex(@split,@s+@split)-1)

/*

--------------------------------------------------

ct

*/

你可能感兴趣的:(F#)