Results 1 to 5 of 5
  1. #1
    Join Date
    Oct 2002
    Posts
    24

    Angry Unanswered: This has to be easy but ...

    How do i return numeric values from a list of numbers in a text column? To elaborate, here is the example:

    i.e., when I go to ORDER BY price, I get results like this:

    14.95
    149.95
    15.95
    164.95

    instead of

    14.95
    15.95
    149.95
    164.95

    Is there an operator in MS-SQL that will allow me to simply return the
    numeric value of a string? Why this price column was created as a text field I still don't know.

    Thanks!
    DataWho

  2. #2
    Join Date
    Jan 2003
    Location
    Chicago, IL, USA
    Posts
    8
    Try

    ORDER BY CAST(price AS numeric)

    although I don't know what this will do to your overhead if you have more than 4 records

  3. #3
    Join Date
    Oct 2002
    Posts
    24

    Cool - but what about the overhead

    Hey it works great thanks!

    Now, are there other data types that might reduce this overhead? Again, this column will only ever store numeric values. So, maybe DOUBLE or DECIMAL or something else might work better? I was searching for good SQL reference material but couldn't find it.

    Thanks!
    DW

  4. #4
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    SQL reference? Books Online

    see CAST and CONVERT


    rudy
    http://rudy.ca/

  5. #5
    Join Date
    Oct 2002
    Posts
    24

    Excellent

    Thanks Rudy, a priceless resource. I've been there before but usually by way of links.

    I think 'smallmoney' does what I need the best!

    DW

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •