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)
 Converting Data Types

Author  Topic 

JohnMcLaughlin
Starting Member

28 Posts

Posted - 2010-11-23 : 11:00:55
How do I convert the data type to compare values in two tables?

The two columns below represent my tables.
I am trying to compare these two values using <>.

0.9604 0.96039999999999992
0.9604 0.96039999999999992
0.8281 0.82810000000000006
0.8281 0.82810000000000006
0.8836 0.88359999999999994

How can i convert the right column to 4 decimal places so that the columns compare.

X002548
Not Just a Number

15586 Posts

Posted - 2010-11-23 : 11:03:36
what are their data types now?

Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2010-11-23 : 11:05:01
SELECT CONVERT(decimal(15,4),0.9604), CONVERT(decimal(15,4),0.96039999999999992)


Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page

JohnMcLaughlin
Starting Member

28 Posts

Posted - 2010-11-23 : 11:08:03
Left was 'Numeric(18,2)' and right was 'float'. But I have multiplied these by other values of the same type.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-11-26 : 09:51:23
quote:
Originally posted by X002548

SELECT CONVERT(decimal(15,4),0.9604), CONVERT(decimal(15,4),0.96039999999999992)


Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/





SELECT CONVERT(money,0.9604), CONVERT(money,0.96039999999999992)


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -