Yeah. I do something like this sometimes:
<cfcquery>
Select *
from table
Where 1 = 1
<cfcase expression="#entity_type#">
<cfswitch value="1">
and this = that
</cfswitch>
<cfswitch value="2">
and that = this
</cfswitch>
</cfcase>
</cfquery>
I use where 1 = 1 sp I don't have to mees around with the wheres and ands.
--
Timothy Heald
Analyst, Architect, Developer
[EMAIL PROTECTED]
W: 202-228-8372
C: 703-300-3911
-----Original Message-----
From: Scott Stewart [mailto:[EMAIL PROTECTED]
Sent: Friday, March 31, 2006 11:19 AM
To: CF-Community
Subject: SQL Question, Switch Case
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:202514
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