1

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,

tomsv
  • 7,017
  • 5
  • 52
  • 87

1 Answers1

3

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

gbn
  • 408,740
  • 77
  • 567
  • 659