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

Problems with Convert-ing VarChar to Numeric 1

Status
Not open for further replies.

danhare

Programmer
Aug 3, 2001
3
GB
Hi
I am trying to get a text string that i am parsing using SubString into a numeric type field.
The number is in the form ;
3,145,554.00

After reading Books Online, I have tried the following syntax in Query Analyzer ;

select convert(numeric , '3,145', 2)

This returns the error ;
Error converting data type varchar to numeric.

Does anyone have any ideas please ?

dan, uk
 
Thanks Robert - i am a bit new still to sp's therefore dont know all the functions that i can use.
however, am i wrong in thinking that the CONVERT syntax that i used SHOULD have worked ?

Thanks again for you amazingly prompt reply.

dan
 

Try double conversion character --> money --> decimal.

select convert(decimal(12,2),convert(money,'3,145,554.00'))

OR

select cast(cast('3,145,554.00' as Money) As decimal(12,2)) Terry L. Broadbent
faq183-874 contains some tips and ideas for posting questions in these forums. Please review it if you have time.
 
Thanks guys.
The conversion to Money type worked fine - my inexperience of the myriad data types i guess !

thanks again.

dan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top