Compare int

  • I have this Varchar datatype column which has numbers and NA.

    Whenever I try to filter out any value the NA comes along with it.

    How can I take care of such a situation?

  • sharonsql2013 (2/26/2016)


    I have this Varchar datatype column which has numbers and NA.

    Whenever I try to filter out any value the NA comes along with it.

    How can I take care of such a situation?

    That's not much to go on. How are you trying to filter out the NA values?

    I would think something like this would suffice.

    SELECT integer_column

    FROM dbo.table_name

    WHERE NOT integer_columns = 'NA';

    Do offer anything further, I'd need to see the table definitions and what you've tried thus far.

  • If you showed what your WHERE clause is, it would be easier to answer this question.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

  • Are the numbers and NA in separate rows or in the same column?

    WHERE [column] LIKE REPLICATE('[0-9]',LEN([column]))

    will check for integer values only

    SELECT LEFT([column],PATINDEX('%[^0-9]%',[column])-1)

    will return numbers before the first character that is not between 0 and 9

    Far away is close at hand in the images of elsewhere.
    Anon.

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

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