日期:2014-05-17  浏览次数:20521 次

请教一下关于SQL变量的小数问题
declare @IRatio decimal(4,4)

select @IRatio=10/30

select @IRatio

如上,我要让 @IRatio 显示为 0.3333 请问要如何处理?
------最佳解决方案--------------------
declare @IRatio decimal(4,4)

select @IRatio=10.0/30

select @IRatio


------其他解决方案--------------------
declare @IRatio decimal(4,4)
 
select @IRatio=10*1./30
 
select @IRatio
------其他解决方案--------------------
declare @IRatio decimal(4,4)

select @IRatio=10.0/30

select @IRatio

加了小数点之后,隐式转换数据类型