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
 General SQL Server Forums
 New to SQL Server Programming
 Why does decimal datatype get rounded ? [RESOLVED]

Author  Topic 

rkeslar
Starting Member

2 Posts

Posted - 2011-03-30 : 09:33:54
In an insert statement, if I have a decimal (9,2) datatype and try to insert a value such as 25.40 it gets inserted in my database as 25.00. Why does this occur? I want it to be inserted as 25.40 as I keyed it in.

Thanks

Seventhnight
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2011-03-30 : 09:36:20
Prove it. Show some sample code reproducing the issue... then we can help.


Declare @d decimal(9,2)

Set @d = 25.40

Select @d

---------------------------------------
25.40

(1 row(s) affected)


Corey

I Has Returned!!
Go to Top of Page

rkeslar
Starting Member

2 Posts

Posted - 2011-03-30 : 09:43:00
quote:
Originally posted by Seventhnight

Prove it. Show some sample code reproducing the issue... then we can help.


Declare @d decimal(9,2)

Set @d = 25.40

Select @d

---------------------------------------
25.40

(1 row(s) affected)


Corey

I Has Returned!!



I found the problem. When you asked me to show some code I looked at my stored procedure I realized my input parameters were declared only as decimal, not decimal (9, 2). That was the problem. Thanks


Is there a way to mark this as resolved? I'm new here.
Go to Top of Page

Seventhnight
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2011-03-30 : 09:44:01
... the best kind of problem. Easy.

Corey

I Has Returned!!
Go to Top of Page

Seventhnight
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2011-03-30 : 09:45:31
Not really... some people change the Title, so it has [Resolved] in it... which is nice. But most people don't bother.

Corey

I Has Returned!!
Go to Top of Page
   

- Advertisement -