sorry, not quite awake yet...

-----Original Message-----
From: BT [mailto:[EMAIL PROTECTED]]
Sent: Thursday, August 02, 2001 9:03 AM
To: CF-Talk
Subject: RE: Dynamic Stored Procedure


Somehow my SQL Statement go cut off but we have <cfquery>select blah blah
<cfif bla1 is "1">do this</cfif> order by your momma</cfquery>

See what I mean

-----Original Message-----
From: Stuart Miller [mailto:[EMAIL PROTECTED]]
Sent: Thursday, August 02, 2001 4:03 AM
To: CF-Talk
Subject: RE: Dynamic Stored Procedure



>I was wondering if there is a way in SQL on SQL7 to say if this variable is
>passed the add a where clause or something......

You can try SQL CASE statements. You will, of course, have to declare the
variables you need in the stored procedure. I have found some performance
issuses with using dynamic sprocs, however. I'm not sure why, but the
execution time can be much greater with the sproc. Might have something to
do with the way SQL server creates the execution plan?

WHERE ........

AND TheDBField = CASE
        WHEN @TheVariable <> 'NO'
        THEN @TheVariable
        ELSE TheDBField
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to