sql - Case statement for 'where [value] is not null' -


i've seen plenty of questions testing null value within case statement, nothing of nature of question. want return of case statement 'is not null' expression clause.

this have:

insert table1 (id) (      select distinct aid id      table2 t2      inner join table3      on (      ...      )      case           when test_value <> '' (another_value not null)       end ) 

this gives error:

incorrect syntax near keyword 'is'.

in short, if test value not empty-string, not want rows another_value=null in table1.

my program needs pass 2 cases

case 1: row#     test_value     another_value    .... 1        'tst'          '919' 2        'tst'           null row 1 should inserted  case 2: row#     test_value     another_value    .... 1        ''             '919' 2        ''              null both rows should inserted 

try this:

where ((isnull(test_value,'') <> '' , isnull(another_value,'') <> '') or isnull(test_value,'') = '') 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -