Professional Web Applications Themes

if statement within if boolean expression - Microsoft SQL / MS SQL Server

is this possible within a stored procedure? if ( 50- (if (var1>4) select 0 else select 10 ) )>=0 select var1...

Sponsored Links
  1. #1

    Default if statement within if boolean expression

    is this possible within a stored procedure?

    if
    ( 50-
    (if (var1>4)
    select 0
    else
    select 10

    )
    )>=0
    select var1


    Sponsored Links
    Antoinette Guest

  2. #2

    Default if statement within if boolean expression

    You can use:

    DECLARE var1 AS INT
    SET var1=4


    DECLARE var2 AS INT
    SET var2=(SELECT CASE WHEN var1>4 THEN
    0 ELSE 10 END )
    IF (50-var2)>=0
    select var1

    However, if I'm reading it correctly then your logic is
    flawed because it will always be >=0. But there it is.

    >-----Original Message-----
    >is this possible within a stored procedure?
    >
    >if
    >( 50-
    >(if (var1>4)
    >select 0
    >else
    >select 10
    >
    >)
    >)>=0
    >select var1
    >
    >
    >.
    >
    DJoe Guest

  3. #3

    Default Re: if statement within if boolean expression

    This is not possible

    As per your logic the result of the outer if statement is always >=0 so I
    don't see what you are trying to achieve.


    "Antoinette" <antoinette_andrewshilton.com> wrote in message
    news:34c201c3400b$6954aa00$a601280aphx.gbl...
    > is this possible within a stored procedure?
    >
    > if
    > ( 50-
    > (if (var1>4)
    > select 0
    > else
    > select 10
    >
    > )
    > )>=0
    > select var1
    >
    >

    Partha Mandayam Guest

  4. #4

    Default if statement within if boolean expression

    sorry-this is not the actual numbers-just used those for
    an example but I will try it that way.
    >-----Original Message-----
    >You can use:
    >
    >DECLARE var1 AS INT
    >SET var1=4
    >
    >
    >DECLARE var2 AS INT
    >SET var2=(SELECT CASE WHEN var1>4 THEN
    > 0 ELSE 10 END )
    >IF (50-var2)>=0
    > select var1
    >
    >However, if I'm reading it correctly then your logic is
    >flawed because it will always be >=0. But there it is.
    >
    >
    >>-----Original Message-----
    >>is this possible within a stored procedure?
    >>
    >>if
    >>( 50-
    >>(if (var1>4)
    >>select 0
    >>else
    >>select 10
    >>
    >>)
    >>)>=0
    >>select var1
    >>
    >>
    >>.
    >>
    >.
    >
    Antoinette andrews Guest

Similar Threads

  1. Replies: 1
    Last Post: November 11th, 12:07 PM
  2. #36675 [Bgs->Opn]: Cannot use an object with boolean expression
    By iain at iaindooley dot com in forum PHP Bugs
    Replies: 0
    Last Post: November 11th, 02:30 AM
  3. Converting Boolean into Bit
    By peteyjr in forum ASP Database
    Replies: 5
    Last Post: January 29th, 04:23 PM
  4. Proftpd - DefaultRoot boolean expression help
    By vishal in forum Sun Solaris
    Replies: 1
    Last Post: July 27th, 02:43 PM
  5. boolean expression regexp
    By zm in forum PERL Miscellaneous
    Replies: 0
    Last Post: July 2nd, 09:44 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