NULL varchar

  • for some reason this query does not work:

    SELECT *

    FROM Orders

    WHERE Event <> 'Point of Sale'

    it fails when the column Orders.Event is NULL. is there a better way to search varchars

    without having to use:

    SELECT *

    FROM Orders

    WHERE ISNULL(Event, '') <> 'Point of Sale'

    SELECT *

    FROM Orders

    WHERE Event NOT LIKE 'Point of Sale%'


    There are ll types of people: those who understand Roman Numerals, and those who do not.

  • By default any comparison to null using =, <> etc. will always compare as false.  When comparing to null try to use IS NULL or IS NOT NULL.

    For example:

    SELECT *

    FROM Orders

    WHERE Event <> 'Point of Sale'

    Or       Event IS NULL

    btw there is nothing wrong with:

    WHERE ISNULL(Event, '') <> 'Point of Sale'

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

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