Using IN operator in Then clause of sql case (inside where)

  • case statement

  • Something like this?

    select * from sys..dm_exec_cached_plans

    WHERE objtype = COALESCE(@obj_type,objtype)

    John

  • @john-2

    The above code worked. Thank you.

  • I actually want to return all the not null records if my obj_type is null. I dont want to return the first not null records.

    For example I have 50 records in the table totally

    if my obj_type is null I want to return all 50 records.

    By using coalesce it is returning only couple of records say 25 which it chooses objtype as 'proc' which is first not null record in table.

    How can I select all records

  • Got the code. Thank you

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply