get sql server to warn about truncation / rounding

喜夏-厌秋 提交于 2019-12-11 10:46:53

问题


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.

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.

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?

Thanks,


回答1:


Look at SET NUMERIC_ROUNDABORT and the table with SET ARITHABORT

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

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



来源:https://stackoverflow.com/questions/6662001/get-sql-server-to-warn-about-truncation-rounding

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!