开发者

Write Decimal numbers in SQL 2008

开发者 https://www.devze.com 2023-01-30 06:12 出处:网络
In need to write the number 7.2 in a table field. What type the field needs to be. And what type needs 开发者_StackOverflow中文版the variable to be? SQL Server 2008 has a DECIMAL type which works quit

In need to write the number 7.2 in a table field.

What type the field needs to be.

And what type needs 开发者_StackOverflow中文版the variable to be?


SQL Server 2008 has a DECIMAL type which works quite well.

You can define a precision (total number of digits) and a scale (number of digits after the decimal separator).

  • DECIMAL(2,1) would be: two digits, one of which after the separator (one before)
  • DECIMAL(5,2) would be: five figits total, two of which after the separator (three before)

See DECIMAL and NUMERIC in SQL Server Books Online for more details

In .NET, this would be a type decimal as well.

0

精彩评论

暂无评论...
验证码 换一张
取 消