Sql Server-实用技巧-字符串类型的百分数怎么转为小数

2020-04-06  本文已影响0人  柠檬正在努力

这个直接放代码,比较简单

declare @str nvarchar(50)

set @str='9%'

if charindex('%',@str)>0

begin

    if ISNUMERIC(replace(@str,'%',''))=1

    begin

        select cast(replace(@str,'%','') as decimal(11,2))/100

    end

end
上一篇 下一篇

猜你喜欢

热点阅读