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)


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

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