Professional Web Applications Themes

Evaluating NULL or len() - Microsoft SQL / MS SQL Server

It will PRINT if "a is not null". a is not NULL so it prints. ('' is not the same as NULL) -- David Portas ------------ Please reply only to the newsgroup -- "Brian G" <com> wrote in message news:034601c355fe$e76584b0$gbl... ...

  1. #1

    Default Re: Evaluating NULL or len()

    It will PRINT if "a is not null".
    a is not NULL so it prints. ('' is not the same as NULL)

    --
    David Portas
    ------------
    Please reply only to the newsgroup
    --

    "Brian G" <com> wrote in message
    news:034601c355fe$e76584b0$gbl... 


    David Guest

  2. #2

    Default Re: Evaluating NULL or len()

    That's because of "or a is not null" check. Since a='' which is not null,
    it has to return true.

    --
    -oj
    RAC v2.2 & QALite!
    http://www.rac4sql.net


    "Brian G" <com> wrote in message
    news:034601c355fe$e76584b0$gbl... 


    oj Guest

  3. #3

    Default Re: Evaluating NULL or len()

    Thanks for the replies. Is there some sort of exclusive
    or I can use so that the statement works?

     
    >
    >
    >.
    >[/ref]
    Brian Guest

  4. #4

    Default Re: Evaluating NULL or len()

    Does this do what you want:

    if (len(rtrim(ltrim(a))) > ''
    ....

    If not, then explain what behaviour you need when (len(rtrim(ltrim(a))) is
    a) NULL
    b) ''
    c) something else

    --
    David Portas
    ------------
    Please reply only to the newsgroup
    --

    "Brian G" <com> wrote in message
    news:022d01c356be$cb7eb6c0$gbl... 
    > >
    > >
    > >.
    > >[/ref][/ref]


    David Guest

  5. #5

    Default Re: Evaluating NULL or len()

    Does this do what you want:

    if rtrim(ltrim(a)) > ''
    ....

    If not, then explain what behaviour you need when rtrim(ltrim(a)) is
    a) NULL
    b) ''
    c) something else

    --
    David Portas
    ------------
    Please reply only to the newsgroup
    --

    "Brian G" <com> wrote in message
    news:022d01c356be$cb7eb6c0$gbl... 
    > >
    > >
    > >.
    > >[/ref][/ref]




    David Guest

  6. #6

    Default Re: Evaluating NULL or len()

    a could be either '', NULL or a string like 'abcde'.

    If a is '' or a is null then I need to Print 'noting for
    a' If a is 'abcde' I need to print 'yep, something for
    a'

     
    (ltrim(a)) is [/ref][/ref]
    NULL) [/ref][/ref]
    print [/ref]
    >
    >
    >
    >
    >.
    >[/ref]
    Brian Guest

  7. #7

    Default Re: Evaluating NULL or len()

    DECLARE a VARCHAR(50)
    SET a=''

    IF a>''
    PRINT 'There is a value for a'
    ELSE
    PRINT 'NOTHING for a'


    --
    David Portas
    ------------
    Please reply only to the newsgroup
    --



    David Guest

  8. #8

    Default Re: Evaluating NULL or len()

    David,

    Cool answer. I tried this out (just because I like to learn new
    things). After further testing, this works when the string is
    alphanumeric characters with ascii values greater 32 (a space), but
    returns "nothing" when it is a special character like CHAR(13) or
    CHAR(10).

    Still, if one one's string does consist only of a tab, newline or
    carriage return, this is a neat trick.

    Thanks for showing this.

    Robert

    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
    Robert Guest

Similar Threads

  1. Evaluating data
    By Wally in forum Coldfusion Database Access
    Replies: 15
    Last Post: October 23rd, 01:22 PM
  2. Evaluating content solutions
    By gniver in forum Macromedia Contribute General Discussion
    Replies: 0
    Last Post: August 28th, 04:00 PM
  3. [PHP] evaluating dynamic variable
    By Matt Matijevich in forum PHP Development
    Replies: 4
    Last Post: September 2nd, 08:54 PM
  4. evaluating dynamic variable
    By Steve Goodman in forum PHP Development
    Replies: 0
    Last Post: September 2nd, 07:54 PM
  5. Evaluating Ruby objectively (not exactly)
    By dblack@superlink.net in forum Ruby
    Replies: 3
    Last Post: August 20th, 05:21 PM

Bookmarks

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139