Tuesday, March 20, 2012

CASE in Select

I am trying to get something lik this working:
select .....
where
...
and user_id =
case @.userid
when <> 0 then @.userid
end
I need to conditionally use user_id = @.userid
when @.userid <> 0
Thankswww.sommarskog.se/dyn-search.html
Adam Machanic
SQL Server MVP
http://www.datamanipulation.net
--
"Mark Goldin" <mgoldin@.ufandd.com> wrote in message
news:%23clOHZ5PFHA.2000@.TK2MSFTNGP15.phx.gbl...
> I am trying to get something lik this working:
> select .....
> where
> ...
> and user_id =
> case @.userid
> when <> 0 then @.userid
> end
> I need to conditionally use user_id = @.userid
> when @.userid <> 0
> Thanks
>sql

No comments:

Post a Comment