日期:2014-05-18 浏览次数:20534 次
declare @str varchar(1000) declare @n int set @n=1 select @str='62.98 242.17 74.51 253.72 5.11 184.27 82.29 261.47 71.69 250.90 59.70 238.89 58.83 238.01 28.70 207.85 106.46 285.65 62.56 241.71' while @n<=17 begin select @str=right(@str,len(@str)-charindex(' ',@str)) select @n=@n+1 end print @str
------解决方案--------------------
declare @sIncludeParaMDL varchar(1000),@nPosi int,@nPosi1 int,@nPosi2 int set @sIncludeParaMDL='62.98 242.17 74.51 253.72 5.11 184.27 82.29 261.47 71.69 250.90 59.70 238.89 58.83 238.01 28.70 207.85 106.46 285.65 62.56 241.71 ' select @nPosi =charindex(' ',@sIncludeParaMDL,1) select @nPosi1=1 select @nPosi2=1 while @nPosi>0 begin --这里是地几个空格 if(@nPosi2=18) select substring(@sIncludeParaMDL,1,@nPosi) --这里是第17个到18之间的数 if(@nPosi2=18) select substring(@sIncludeParaMDL,@nPosi1,@nPosi-@nPosi1) --select @nPosi,@nPosi1,@nPosi2 select @nPosi1 = @nPosi+1,@nPosi2=@nPosi2+1 select @nPosi =charindex(' ',@sIncludeParaMDL,@nPosi1) end