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 |
jess
Starting Member
17 Posts |
Posted - 2007-08-16 : 10:23:29
|
Hi, I have a question about the Money data type.Sometimes there are fractions of pennies out there in our database, and I want to find all of those fractions. Basically I want to find all of the entries in a table that have a value other than 0 in the 3rd digit to the right of the decimal place. (For example, the 1 in the value $5.0010)Can anyone help me do this?Here's some sample code for a table with 3 entries. 2 of the entries have fractions of pennies, so that is what I want the end result to return.DECLARE @amounts TABLE ( id int, value money )INSERT INTO @amountsSELECT 1, 5.0010INSERT INTO @amountsSELECT 2, 3.3500INSERT INTO @amountsSELECT 3, 6.0010What I need is some sort of statement to pull the values that have fractions. Like:SELECT *FROM @amountsWHERE --?? Value in the 3rd place to the right of the decimal is not 0The results should then be:id value1 5.00103 6.0010Any help would be very much appreciated!!!Thanks!Jess |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-08-16 : 10:26:17
|
[code]SELECT *FROM @amountsWHERE CONVERT(int, value * 1000) % 10 <> 0[/code] KH[spoiler]Time is always against us[/spoiler] |
 |
|
jess
Starting Member
17 Posts |
Posted - 2007-08-16 : 10:34:28
|
Genius! That is exactly what I needed.Many thanks!Jess |
 |
|
|
|
|