Convert Varchar into numeric

  • Hi

    I have a varchar value like 0.365 that i want to do calculations with. How do I turn this value into a datatype that I can calculate??

     

    How do I convert it??

     

    Regards Mattias

  • Hi Mattias,

    Have you tried CONVERT(decimal,ColumnName). I used a decimal here as your exmaple in your post showed 0.365

    Anton

  • You might like to qualify 'decimal' with 'precision' and 'scale' arguments - eg decimal(9,5) gives you 9 decimal positions per number to play with - up to five of them to the right of the decimal point - check BOL for more details.

    The advantage here is that less memory is used (5 bytes, instead of the default 17 per decimal number)

    The absence of evidence is not evidence of absence
    - Martin Rees
    The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
    - Phil Parkin

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply