复制代码 代码如下:
declare @bl decimal(10,6),@num int,@num1 int ,@str char(20),@str1 char(20),@str2 char(20),@str3 char(20),@zx int,@zx1 int
set @bl=1110.10000
set @str1=ltrim(REVERSE(cast(@bl as char(30)))) ---颠倒
print @str1
set @zx1=cast(@bl as int)
set @str2=cast(@zx1 as char(10)) --取整数部分
print @zx1
set @num=len(@str2)
print @num
set @num1=charindex('.',@str1)
print @num1
set @str1=substring(@str1,0,@num1)
set @zx1=cast(@str1 as int)
print @str1
set @str3=ltrim(REVERSE(cast(@zx1 as char(10)))) --取小数部分
if @str3=0
set @str=rtrim(cast(@str2 as char(20)))
else
--print @str2
--print @str3
set @str=rtrim(cast(@str2 as char(20)))+'.'+rtrim(cast(@str3 as char(6)))
print @str
---set @str3=cast(@str2 as decimal(10,6))
新闻热点
疑难解答