Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access SQL String to Numeric - not returning data after decimal point, not changing data type 1

Status
Not open for further replies.

NWildblood

Technical User
Nov 12, 2007
113
GB
Hi, I have an Access SQL query to convert String to Numeric, however it is returning whole integers only - not returning numbers after decimal points.

The table concerned has mileages in 000.0000 format as string, (it's data extracted from a very old database) however the SQL below is returning whole numbers only

E.g. 123.1234 (string) is updated to 23 (numeric)

The SQL is here.

UPDATE Route_Master SET Route_Master.MILEAGE_FROM = Clng ([MILEAGE_FROM]);

Another observation - after completing the query, the Data Type remains "Text", when I expected to see "Number"

Any help very gratefully received !

No hay nada como un buitre cabrón como un ojo de cristal.
 
hi,

Your update query is ONLY converting a STRING to LONG and converting that LONG back to STRING, which is how that field is defined.



Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 


That's whey I stated LONG. It is an integral data type!

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
Thanks for the replies guys, so can I use SQL to convert the actual data type, or will I need to use Function/VB ?
Thanks again

No hay nada como un buitre cabrón como un ojo de cristal.
 
I think you're gonna need to create a new table with correct field types, update that table.

Then delete the old table and rename the new table.

This is a one time event, YES?

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
or maybe add a column with correct data type. Update THAT column.

Then delete the old string column once you're satisfied.

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
That's a good plan, I had avoided doing that because it's such a huge table, but I'll go for it now - cheers Skip !

No hay nada como un buitre cabrón como un ojo de cristal.
 
Anyway, why not simply use the Val function ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
OutOfShape, did you even try to use the Val function ?
 
I did PHV, and it all worked fine earlier, thank you for that, bad day at the office yesterday !

No hay nada como un buitre cabrón como un ojo de cristal.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top