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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Converting datatype Varchar to numeric

Status
Not open for further replies.

nread

Technical User
Oct 31, 2001
58
0
0
GB
I have a problem converting a Varchar datatype into a numeric field....

The values in my table are to 3 deimcal places and are of datatype varchar.

When i use Convert(decimal(10,3),col7) for a value of .0123
it returns the value .012.

Any ideas how i can convert a varchar to numeric but keeping the the 3 decimal places...?

Cheers in advance.....
 
unless I'm mistaken .0123 is 4 decimal places so you want

Convert(decimal(10,4),col7)


Matt

Brighton, UK
 
Matt

Appologies, that was a mistake. Regrardless of the value i still will not do it.

I have a problem converting a Varchar datatype into a numeric field....

The values in my table are to 3 deimcal places and are of datatype varchar.

When i use Convert(decimal(10,4),col7) for a value of .0123
it returns the value .012

Any ideas how i can convert a varchar to numeric but keeping the the 3 decimal places...?

Cheers in advance.....
 
Hi nread,

I think that it is your connection settings, that why you are getting the wrong resulst. Otherwise the command is perfect.

Just go to Connections tabl under TOOLS-->OPTIONS. And un-check the 'Use regional settings when displaying currency, number, dates, and times'. After doing this run your query and you will get the proper result.

If still some problem, just revert back.


Raj
 
I will give that ago seems to make sense. Though i got so fed up with it i ran a pass through from access and re-created in Access just to get a result...!!

Thanks for your help though.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top