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
 trailing zeroes with smallmoney

Author  Topic 

elic05
Yak Posting Veteran

62 Posts

Posted - 2009-07-26 : 10:47:32
the dataType for the price cell is smallmoney
on the local host it behaves fine
if i insert the value 2.25 in the table i fine the exact number

but on the remore server
i see in the table
2.2500
always 4 digits after the decimal point.
why??

can it be fixed, that it will get the exact number i insert?

the second question
how to write a query that will delete all the trailing zeroes
(sometime it has to delete also the point e.g. 5.0000 has to be 5)
thanks

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-07-26 : 11:36:47
This makes no sense to me.
It is the job of the database to store the data in the right format depending on the datatype and not depending of any format you want to display.
You should do that kind of formatting in your front end.


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

elic05
Yak Posting Veteran

62 Posts

Posted - 2009-07-26 : 12:29:30
i dont no if it make sense, but it is the fact
i insert data (e.g. 2.25) to the table using the same query
on the local machin i see in the table 2.25
and on the remote server i see 2.2500
it nust be somthing with the DB definitions.

and what about the second question?
a query to change the already inserted data?
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-07-26 : 13:39:35
quote:
it nust be somthing with the DB definitions

No, it must be something with the client config.

quote:
and what about the second question?
a query to change the already inserted data?


Believe it or not. SQL Server has its internal format for the datatype and there is NO update to change the data because it is in fact a display-problem not a data-problem.


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

elic05
Yak Posting Veteran

62 Posts

Posted - 2009-07-26 : 16:27:48
even more ineresting!
when i open the remote database with mssmse i see in the table that all the price column is formatted with 4 digits after the decimal period.
but when i query the db
select price from myProducts
i get all the prices with only 2 digits after the decimal period.
Go to Top of Page

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2009-07-26 : 18:01:16
2.25 and 2.2500 are the same thing. do the formatting in the front end (as webfred said)
Go to Top of Page
   

- Advertisement -