Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Jul 2002
    Location
    Houston, TX
    Posts
    84
    Thanks
    0
    Thanked 0 Times in 0 Posts

    (ASP & MS SQL 2000) How do I recognize a NULL out of a SELECT statement?

    How do I recognize a NULL out of a SELECT statement? I need to determine when a field is null but I cant seem to get it. I tried "if len(field) = 0" and "if field = NULL" but neither would fire.
    Thanks in advance,
    Michael

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Location
    Cincinnati, OH
    Posts
    545
    Thanks
    0
    Thanked 0 Times in 0 Posts
    try

    Is Null
    or
    Is Not Null

  • #3
    New Coder
    Join Date
    Jul 2002
    Location
    Houston, TX
    Posts
    84
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I tried that... "if field is null" hits every time (even when not null) I also tried "if field = """ and "if field = false" and they don't hit even when null
    any other ideas?
    Thanks
    Michael

  • #4
    New Coder
    Join Date
    Jul 2002
    Location
    Houston, TX
    Posts
    84
    Thanks
    0
    Thanked 0 Times in 0 Posts
    as a workaround I sorted the query by the field that I need to find the null and that worked for this situation (because I know how the data is constructed). But that wont work for many other situations.
    Michael

  • #5
    Senior Coder
    Join Date
    Jun 2002
    Location
    Wichita
    Posts
    3,880
    Thanks
    0
    Thanked 0 Times in 0 Posts
    If IsNull(variable) then ...

    I've used this many times so I know it works.

  • #6
    Senior Coder
    Join Date
    Jun 2002
    Location
    41° 8' 52" N -95° 53' 31" W
    Posts
    3,660
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I use the same setup at work, and this almost always works for me:

    WHERE fieldname IS NULL

    Or, as an alternative (this usually works when the above doesn't):

    WHERE fieldname = '' (that's two single quotes!)

    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)


  •  

    Posting Permissions

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