今天在sqlserver中,调用存储过程中遇到convert转换数据失败,导致后面的存储过程语句未执行的问题。当前还没有了解具体原因
主要是因为在使用substring函数时,字符串越界,不过substring函数到没有出现问题,而导致下句调用convert转换时语句未能继续下去
(
set @tempstr = substring(@str, @ipos + 1, @i - @ipos)少减去1
/*print @tempstr*/
set @param1 = convert(float, @tempstr)
set @tempstr = substring(@str, @ipos + 1, @i - @ipos - 1)
/*print @tempstr*/
set @param1 = convert(float, @tempstr)
)
先做下记录
以后在调用convert等转换函数时需要做次判断处理,在继续转换处理,防止以后出现类似的问题。
case when isdate(col)=1 then '可以转换为数字' when isnumeric(col)=1 then '可以转换为日期' else '既不能转换为数字,也不能转换为日期'end