Email lists > aspnet at aspadvice.com > [aspnet] Re: SQL GURU: IN operator with Case Statement > [aspnet] Re: SQL GURU: IN operator with Case Statement

[aspnet] Re: SQL GURU: IN operator with Case Statement




This post if a part of  this thread

2008-06-10 11:25:47
Re: SQL GURU: IN operator with Case Statement
SELECT
     t.blah
     , t.blah2
FROM
     tblBlah t
WHERE
     exists (
         select 1 where parm = 0

         union all

         SELECT 1 FROM tbl t2
         where t.intCodes = t2.intCodes
     )


Tim Curtin wrote:
> Hello folks,
>  
> I'm trying to set the hard-coded values or the parm in a
IN operator 
> without using dynamic SQL.
>  
> I've tried a couple of different approaches.  This most
recent one 
> doesn't work
>  
>  
> declare tbl TABLE
> (
>      intCodes INT
> )
>  
> INSERT tbl select 123
> INSERT tbl select 456
> INSERT tbl select 789
>  
> SELECT blah, blah
> FROM tblBlah
> WHERE intField IN (   CASE WHEN parm = 0 THEN
>                                  (SELECT intCodes FROM
tbl)
>                              ELSE
>                                   parm
>                              END)


--- List Settings ---
http://aspadvice.com/list
s/


about | contact  Other archives ( Real Estate discussion Medical topics )