为什么SELECT语句在SQL Server中返回12? [英] Why SELECT statement returns 12 in SQL server ?

查看:107
本文介绍了为什么SELECT语句在SQL Server中返回12?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

DECLARE @retTable TABLE
    (
      ArtilceID INT ,
      Quantity DECIMAL
    )
INSERT  INTO @retTable
        ( ArtilceID, Quantity )
VALUES  ( 1, 11.5 )
SELECT  *
FROM    @retTable





您好。

感谢

为什么SELECT语句在Sql server中返回12?



谢谢



我尝试过:



我需要知道re ason for this。



Hi.
thanks for
Why SELECT statement returns 12 in Sql server ?

thanks

What I have tried:

I need to know the reason for this.

推荐答案

尝试阅读 DECIMAL [ ^ ] 下次。您没有提供精度和比例,因此默认值是18位数的精度和0的比例.Scale是小数点右边的位数,因此对于值为0的DECIMAL存储整数只有。
Try reading the documentation on DECIMAL[^] next time. You didn't supply a precision and scale so the defaults are a precision of 18 digits and a scale of 0. Scale is the number of digits to the right of the decimal point, so for a value of 0 that makes DECIMAL store integer numbers only.


试试这个:它会提供你想要的输出:



Try this: It will give output as you want to be:

DECLARE @retTable TABLE
    (
      ArtilceID INT ,
      Quantity DECIMAL(4,1)
    )
INSERT  INTO @retTable
        ( ArtilceID, Quantity )
VALUES  ( 1, 11.5 )
SELECT  *
FROM    @retTable





输出将是:



Output will be :

ArtilceID	Quantity
  1	          11.5


这篇关于为什么SELECT语句在SQL Server中返回12?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆