locked
Converting issue in MS SQL SERVER RRS feed

  • Question

  • User779033375 posted

    Hi,

    IN database I have a Varchar column (COLUMN1) with ">50000" value.

    How can I write a condition in SQL to validate againest ">50000"

    e.g: select * from ABC where COLUMN1 > 500

    Now in COLUMN1 has value ">50000" need to fetch this value with above query.

    Wednesday, July 24, 2013 3:43 AM

Answers

  • User-1716253493 posted

    Do you want to validate it as varchar or numeric?

    select * from ABC where CAST(REPLACE(COLUMN1,'>','') as INT) > 500



    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, July 24, 2013 3:49 AM

All replies

  • User-1716253493 posted

    Do you want to validate it as varchar or numeric?

    select * from ABC where CAST(REPLACE(COLUMN1,'>','') as INT) > 500



    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, July 24, 2013 3:49 AM
  • User779033375 posted

    Thank you for you reply.

    I need to validate the number.

    Will try to implement the solution.

    Do you want to validate it as varchar or numeric?
    select * from ABC where CAST(REPLACE(COLUMN1,'>','') as INT) > 500


    Wednesday, July 24, 2013 9:42 AM