View Single Post
  #11 (permalink)  
Old 06-27-07, 08:58
Wim Wim is offline
Registered User
 
Join Date: Nov 2004
Posts: 1,159
the solution
Quote:
replace(replace(rtrim(ltrim(replace(char(<FIELD_NA ME>), '0', ' '))), ' ', '0'), '.', '')
fails for negative numbers and numbers with digits after the decimal point.

Code:
number          CHAR CAST       REPLACE solution
10000,050	00010000.050 	1000005
20000,000	00020000.000 	20000
-4000,000	-00004000.000	-00004000
__________________
With kind regards . . . . . SQL Server 2000/2005/2008/2008 R2 Earned beers: 13
Wim
Beware of bugs in the above code; I have only proved it correct, not tried it. -- Donald Knuth
Grabel's Law: 2 is not equal to 3 -- not even for very large values of 2.
Pat Phelan's Law: 2 very definitely CAN equal 3 -- in at least two programming languages

Last edited by Wim; 06-27-07 at 09:02.
Reply With Quote