让SQL Server来警告截断/舍入 [英] get sql server to warn about truncation / rounding

查看:131
本文介绍了让SQL Server来警告截断/舍入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作的一个ASP.NET的C#应用​​程序的会计,我在使用花车过渡/加倍使用小数重新present钱。

I am working on an ASP.NET C# accounting app and I am in the transition from using floats/doubles to using decimals to represent money.

现在我想控制在何时何四舍五入发生。
我的理解是,SQL服务器不同小数四舍五入数据类型比C#一样。

Now I want to control when and where rounding takes place. The way I understand it, SQL server rounds decimal data types differently than C# does.

有没有办法让SQL服务器(2008年),警告或失败,如果十进制值(或任何类型的数据)越来越截断或四舍五入?

Is there some way to get SQL server (2008) to warn or fail if decimal values (or any kind of data) are getting truncated or rounded?

谢谢,

推荐答案

SET NUMERIC_ROUNDABORT 和SET ARITHABORT表

Look at SET NUMERIC_ROUNDABORT and the table with SET ARITHABORT

这决定了什么什么的发生是否。该事(错误或警告)取决于SET ARITHABORT。但是,你会得到为NULL的警告。

This determines whether nothing or something happens. The something (an error or warning) depends on SET ARITHABORT. However, you get NULL for a warning.

我会考虑在客户端code做你的计算,或使用广泛小数(如38,20),以减轻它

I'd consider doing your calculations in the client code, or use a wide decimal (eg 38,20) to mitigate it

这篇关于让SQL Server来警告截断/舍入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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