declare @S VARCHAR(1000) declare @ssum VARCHAR set @ssum=0.0 set @S='招待蓝德堡胶水二人花132元.' set @S=replace('招待蓝德堡胶水二人花132元.','\','') set @S=replace('招待蓝德堡胶水二人花132元.','\\','') WHILE PATINDEX('%[^0-9\\.\\^0-9]%',@S)>0 begin IF PATINDEX('%[^0-9\\.\\^0-9]%',@S) = 1 BEGIN SET @S = STUFF(@S,PATINDEX('%[^0-9\\.\\^0-9]%',@S), 1, ''); END else BEGIN SET @ssum=cast(@ssum as numeric(18,2))+cast(substring(@S,0,PATINDEX('%[^0-9\\.\\^0-9]%',@S)) as numeric(18,2)) set @S=substring(@S,PATINDEX('%[^0-9\\.\\^0-9]%', @S),len(@S)) END end |