0

How can I store a .NET double in an SQL Server 2008 data type?

I get an exception 'Parameter value '1.3465492655247000' is out of range' when I try to store a double in a numeric(16, 16) column. Because the number has 16 decimal place and a 1 in front. numeric(16.16) is the maximum i can set in SQL Server for that type.

I created an ADO.NET dataset in C# and there the column is set as decimal. I cast the double to a decimal.

This site shows the SQL Server 2008 data types

1 Answer 1

1

numeric(16, 16) allows a number of length 16 with all 16 digits reserved for the digits after the decimal point.

You can go up to numeric(38, 16). This will allow up to 22 digits to the left of the decimal point and 16 to the right.

This doesn't quite allow the full range of ±1.0 × 10^28 to ±7.9 × 10^28. If you need numbers that large you would need to reduce the amount of digits reserved for decimal places.

Sign up to request clarification or add additional context in comments.

1 Comment

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.