sql server 2005 - TSQL remove decimal under certain condition -


i have problem database in user has inputted decimal comma go on frequent basis. work on correcting issue going forward need fix 100 plus records entered. mix of correct location , incorrect locations

small example:

153.30 129.30 152.709 153.308 108.777 21.369 

i want preserve entries decimal indicating cents, , remove decimal should have been comma such.

153.30 129.30 152709 153308 108777 21369 

i think you're going have real hard time here, , may quickest spot check 100 rows , fix them manually. here's why:

declare @x table(m money);  insert @x select 153.30  union select 153.300;  select m @x; 

results:

m ------ 153.30 153.30 

sql server present identical. couldn't figure out way convert string (or binary, or other type), either implicitly or explicitly, tell 2 values apart once arrived in table.

now, may able narrow down, three-digit decimals don't end in zero:

declare @x table(m money);  insert @x select 153.30  union select 153.300 union select 153.309 union select 24.125;  select m @x m * 1000 % 10 > 0; 

results:

m ------- 153.309  24.125 

but ones end in zero, you're on own. so, fix data, slap user's wrist, , move on.


Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -