判断是否有百分号,去除百分号,判断如果是数字就转化为小数,直接上代码:
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
判断是否有百分号,去除百分号,判断如果是数字就转化为小数,直接上代码:
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
本文标题:Sql Server-实用技巧-nvarvhar中的百分数怎么转
本文链接:https://www.haomeiwen.com/subject/sjxywhtx.html
网友评论