I store some numbers in a ‘real’ type field.
I insert/read values to/from it from my c# application using ADO.net. When I query my data in Server Management Studio I can see it converts my numbers into scientific normal format, like: 2,211221E+07. I did not set anythig to do this, everything is default.
How can I avoid this behaviour?
MS SQL Server 2008 Express/.Net 4/VS2010
It doesn’t convert your reals (IEEE floating points) into scientific format: that’s how it displays them in SSMS. Here’s how ADO.Net maps data types between SQL Server and the .Net world: http://msdn.microsoft.com/en-us/library/cc716729.aspx
For floating point types, SQL Server implements the ISO data type
float(n), where n is the size of the mantissa in bits (1-53 inclusive).realis a synonym forfloat(24);floatis a synonym forfloat(53).Rather as you might expect, floating point columns with a mantissa 1-24 bits in size are mapped to/from
System.Single; whilst those with mantissa more than 24 bits in size are mapped toSystem.Double.Sql Server’s
moneyandsmallmoneydata types really have little to do with money. They are just fixed-precision decimals, with a precision of 4 decimal places (1/10000 of a unit). Ado.Net mapsmoneyandsmallmoneytoSystem.Decimaland mapsSystem.Decimaltomoney(there is no mapping tosmallmoney). This conversion suffers from something of an impedance mismatch, however,System.Decimalbeing a decimal floating point format. The conversion to/from SQL Server’smoneydatatype can result inSystem.Decimalvalue has more than 4 digits to the right of the decimal point, the extra digits are lost.