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.
Author |
Topic |
arkiboys
Master Smack Fu Yak Hacker
1433 Posts |
Posted - 2012-07-02 : 08:11:16
|
Hi,The select query retrieves a field which is of type floatThe value returned is: 138634.4698declare @value1 floatdeclare @value2 floatselect @value1 = value1, @value2 = value2from tblMain where ID = 1In the table the value1 and value2 are 138634.4698 and 1865657.02 respectively.Questions:1- Do you know why my print statement below shows the value1 as 138634 ?print 'value1 -->' + convert(varchar(50), @value1)2-Do you know why my print statement below shows the value2 as 138634 ?print 'value2 -->' + convert(varchar(50), @value2)Thanks |
|
yosiasz
Master Smack Fu Yak Hacker
1635 Posts |
Posted - 2012-07-02 : 12:27:12
|
things are floating arounddeclare @value1 floatdeclare @value2 floatdeclare @value3 nvarchar(50)declare @value4 nvarchar(50)select @value1 = 38634.4698select @value3 = convert(decimal(10,4),@value1)select @value2 = 1865657.02select @value4 = convert(decimal(10,2),@value2)print 'value1 -->' + @value3print 'value2 -->' + @value4<><><><><><><><><><><><><><><><><>If you don't have the passion to help people, you have no passion |
 |
|
arkiboys
Master Smack Fu Yak Hacker
1433 Posts |
Posted - 2012-07-04 : 07:16:34
|
Thanks |
 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-07-04 : 18:57:40
|
float is an approximate decimal value so if you want decimal level accuracy go for decimal or numeric------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
yosiasz
Master Smack Fu Yak Hacker
1635 Posts |
Posted - 2012-07-05 : 12:08:07
|
sure thing<><><><><><><><><><><><><><><><><>If you don't have the passion to help people, you have no passion |
 |
|
|
|
|