Or to more directly tie in with your question:
SELECT *
FROM MY_FAKE_TABLE
WHERE FAKE_COLUMN = CASE
WHEN FAKE_COLUMN_2 = 'A' THEN @ARGUMENT_A
WHEN FAKE_COLUMN_2 = 'B' THEN @ARGUMENT_B
ELSE @ARGUMENT_DEFAULT
END
On 3/31/06, Chris Stoner <[EMAIL PROTECTED]> wrote:
>
> Yes to a point...such as you can do something like my example below (not
> tested,obviously). The issue you will run into is that you wont be able to
> have a where clause with multiple filters. You basically can use the case
> statement to equate a specific column to another column depending on the
> condition.
>
> SELECT *
> FROM MY_FAKE_TABLE
> WHERE FAKE_COLUMN = CASE
> WHEN FAKE_COLUMN_2 = 'A' THEN FAKE_COLUMN_3
> WHEN FAKE_COLUMN_2 = 'B' THEN FAKE_COLUMN_4
> ELSE FAKE_COLUMN_5
> END
>
>
>
>
> On 3/31/06, Scott Stewart <[EMAIL PROTECTED]> wrote:
> >
> > All,
> >
> >
> >
> > Can you use a switch case statement to build a dynamic where clause
> > based on
> > parameters passed to a stored procedure?
> >
> > I'm using T-SQL in SQLServer 2000
> >
> >
> >
> > IE:
> >
> >
> >
> > Case where entity_type is X
> >
> > "piece of where clause"
> >
> > Case where enity_type is Y
> >
> > "piece of where clause"
> >
> >
> >
> > Thanks
> >
> >
> >
> > Scott
> >
> >
> >
> > Scott A. Stewart
> >
> > Webmaster/ Developer
> >
> > GlobalNet Services, Inc
> >
> >
> >
> > <http://www.gnsi.com> http://www.gnsi.com
> >
> > 11820 Parklawn Dr
> >
> > Rockville, MD 20852
> >
> > Voice: (301) 770-9610 x 335
> >
> > Fax: (301) 770-9611
> >
> >
> >
> > The information contained in this message may be privileged,
> > confidential,
> > and protected from disclosure. If the reader of this message is not the
> > intended recipient, or any employee or agent responsible for delivering
> > this
> > message to the intended recipient, you are hereby notified that any
> > dissemination, distribution, or copying of this communication is
> > strictly
> > prohibited. If you have received this communication in error, please
> > notify
> > us immediately by replying to the message and deleting it from your
> > computer.
> >
> >
> >
> >
> >
> >
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Message: http://www.houseoffusion.com/lists.cfm/link=i:5:202425
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/5
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:5
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.5
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54