Results 1 to 2 of 2

Thread: qry

  1. #1
    Join Date
    Oct 2002
    Posts
    36

    Unanswered: qry

    i have a doubt in the following qry.the following table contains "status
    field with "Null" ,"D","M","Z" data. iwant the data with status "NUll"
    and "D" but the following qry not checking nulls how to chk and get the infor in SQL SERVER



    SELECT fileidmodifier,
    filename,status
    fileid
    FROM ALLFILEHEADER
    WHERE (immediateorigin = '063111596'
    OR immediatedest = '063111596' )
    AND convert(varchar(10),filecreationdate,101)='07/19/2002'
    AND status not in ('M','Z')
    ORDER BY fileidmodifier

  2. #2
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1

    Re: qry

    The only way to test for NULL values is with IS NULL (or IS NOT NULL to test for non-NULLs). So instead of:

    AND status not in ('M','Z')

    you must say either:

    AND (status IS NULL OR status not in ('M','Z'))

    or:

    AND (status IS NULL OR status = 'D')

Posting Permissions

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