Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Decimal values are getting rounded unwillingly

Author  Topic 

dogmatic
Starting Member

2 Posts

Posted - 2010-02-09 : 17:07:50
Hi there,

I am inserting into a table column of type numeric(18,4). This should be able to store values like 0.22334 and 145.334495. However, when I run my stored procedure and pass 2.3348 in as the value it gets stored as 2.0000. Likewise, 0.334 becomes 0.000!

Any ideas why?

Thanks!

Kristen
Test

22859 Posts

Posted - 2010-02-09 : 17:14:31
Please post the DDL for the CREATE TABLE / COLUMNS and the INSERT statement

If it is numeric(18, 4) no rounding would occur - so must be some other side-effect.
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2010-02-09 : 17:25:34
Sound like
1) INT parameter
2) not using the locale's decimal sign


N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

dogmatic
Starting Member

2 Posts

Posted - 2010-02-10 : 13:34:57
Thanks Kristen! It was a problem with my stored procedure. I declare the parameter as

@CriteriaValue numeric

instead of

@CriteriaValue numeric(18,4)
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2010-02-11 : 06:18:38
I wish SQL would "warn" for that scenario. All too easy to do, very hard to see it though
Go to Top of Page
   

- Advertisement -