Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2003
    Location
    Cape Town
    Posts
    38

    Unanswered: Problem with null fields and case statement

    Can someone help me with this :

    Case WHEN ISNULL (dbo.BLH.n1name,'NOTHING')= 'NOTHING' then dbo.BLH.coname else dbo.BLH.n1name End as CustName

    as the strored proc is not returning value when the fileds is blank

    cheers
    Benone

  2. #2
    Join Date
    Apr 2004
    Location
    Kansas City, MO
    Posts
    734
    NULL and blank aren't the same thing. NULL is unknown.

    CASE WHEN ISNULL(dbo.BLH.n1name,'')='' THEN dbo.BLH.coname ELSE dbo.BLH.ntname END AS CustName

    That should work for you unless you have spaces of course. In that case you would need:

    CASE WHEN ISNULL(LTRIM(RTRIM(dbo.BLH.n1name)),'')='' THEN dbo.BLH.coname ELSE dbo.BLH.ntname END AS CustName
    MeanOldDBA
    derrickleggett@hotmail.com
    When life gives you a lemon, fire the DBA.

  3. #3
    Join Date
    Oct 2003
    Location
    Cape Town
    Posts
    38
    It Works . Thanks
    Benone

Posting Permissions

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