NOT NULL and Spaces

  • Hi,

    I'm trying to eliminate all rows where the column is either NOT NULL or contains spaces. So my query is something like this:

    SELECT * FROM MYTABLE

    WHERE (STATUS IS NOT NULL OR STATUS <> ' ')

    The query eliminates the NULL's but still returns back the column with spaces.

    Any ideas on what I'm doing wrong would be greatly appreciated??

  • Change the OR to an AND.

  • Try this..

    select * from mytable where isnull(ltrim(rtrim(status)),'')<>''

  • Thanks ever so much. That worked great.

  • WHERE STATUS>''


    Madhivanan

    Failing to plan is Planning to fail

  • dale_keller (11/5/2008)


    Thanks ever so much. That worked great.

    Which way did you fix your problem?

  • I used this as an example:

    select * from mytable where isnull(ltrim(rtrim(status)),'')<>''

    works great!!!!

  • Sounds good. Again, just curious, did you try changing the OR to AND in your original query?

  • Yes, and it still did not work.

  • Lynn yours would work if you LTRIM RTRIM the status first.

    ----------------------------------------------
    Try to learn something about everything and everything about something. - Thomas Henry Huxley

    :w00t:
    Posting Best Practices[/url]
    Numbers / Tally Tables[/url]

    SQL-4-Life
  • Christopher Stobbs (11/5/2008)


    Lynn yours would work if you LTRIM RTRIM the status first.

    I thought so. I just attacked the obvious BOOLEAN error in the original code and didn't really notice that there could have been values with multiple spaces (ie ' ') since the code had status <> '' in the where clause.

Viewing 11 posts - 1 through 10 (of 10 total)

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