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 2005 Forums
 Transact-SQL (2005)
 Round Off Problem when Assigning data in local var

Author  Topic 

khufiamalik
Posting Yak Master

120 Posts

Posted - 2008-10-27 : 02:52:50
Hello All,
I have a problem in Sql Query.
I have Amount filed , when I Do query on that field ,it gives the right value which is 3.2097.
when I use the same query in Sp and assign the result in a variable(in my SP) then it shows 3.21

I just want to get the original value.
Can any one help me
Query is like


'Select Amount from Employee where ID=1'


result = 3.2097

AND Query in SP is like

Declare @lLocalVar as Money
Select @lLocalVar=Amount from Employee where ID=1


Result =3.21

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-10-27 : 02:55:57
duplicate
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=113321
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-10-27 : 03:08:11
Whats the datatype of Amount? is it also money?
Go to Top of Page

khufiamalik
Posting Yak Master

120 Posts

Posted - 2008-10-27 : 03:52:48
Yes it is also Money
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-10-27 : 04:02:50
And i assume you're using same query and not doing any other operations or using it as part of some other query.
Go to Top of Page

khufiamalik
Posting Yak Master

120 Posts

Posted - 2008-10-27 : 05:21:14
No I have been running the same query as mentioned in my Mail.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-10-27 : 06:21:01
it looks fine to me on running

declare @m money

select @m=3.2097
select @m

output
--------------------------
3.2097
Go to Top of Page

Transact Charlie
Master Smack Fu Yak Hacker

3451 Posts

Posted - 2008-10-27 : 06:49:45
Would it be possible to post the whole code of the sp? There may be some implicit conversion taking place that you're not aware of.

Regards,

-------------
Charlie
Go to Top of Page
   

- Advertisement -