Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
Hithere is something strange in the code below: declare @a money set @a=1.2365 print cast(@a as varchar(10))when i run the code in the query analizer , the output will be rounded and always will be displayed with two decimal digits(=1.24)...why?how can i move the whole number value as an string value to an string variable without this truncation?Thanks.kind Regards.
rmiao
Master Smack Fu Yak Hacker
7266 Posts
Posted - 2008-05-05 : 23:04:05
The money and smallmoney data types are accurate to a ten-thousandth of the monetary units that they represent. If you like to see whole number, you can cast it to decimal.
Anoop
Starting Member
6 Posts
Posted - 2008-05-06 : 04:04:25
Money data type will always round upto 2 decimal point. If you want to use decimal, try this.declare @a decimal(10,4)set @a=1.2365print cast(@a as varchar(10))