Вопрос

i declared a column as numeric(5,3) in sql server 2008 exp r2 and i assumed that it would allow me to save values like 12345.123 but when i tried to enter anything greater than 100 it gives me overflow error. it made me believe that in numeric(5,3), 5 represents the total length of number including precision and scale. Having this in mind, i changed the type of column to decimal(9,3) and assumed that it would allow me to enter values like 123456.123 but it again gives overflow error. I can't understand how this datatype and its precision and scale is interpreted by sql server.
Update:
Strange thing is that when inserting value numeric(9,3) only allows to enter values like 1234.123 but when editing the row i can enter value 123456.123. don't know what's happening here :(

Это было полезно?

Решение

decimal(9,3) should work fine for 123456.123 please recheck!

Executing

declare @d decimal(9,3) = 123456.123 

gives no error. This datatype allows 6 digits to the left of the decimal point and 3 to the right.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top