may not have to do that if you try the following
<cfquery name="test" datasource="abcinc">
select *
from profiles
where 0=0
<cfif isdefined('form.firstname')>
<cfif form.firstname neq ''>
and firstname='#form.firstname#'
</cfif>
</cfif>
<cfif isdefined('zipsreturned')
<cfif zipsreturned neq ''>
and zipcode in (<cfqueryparam cfsqltype="cf_sql_varchar"
value="#zipsreturned#" list="yes">)
</cfif>
</cfif>
</cfquery>
-----Original Message-----
From: Pardeep Singh [mailto:[EMAIL PROTECTED]
Sent: Monday, February 21, 2005 1:32 PM
To: CF-Talk
Subject: How u convert this cfquery to TSQL for MS SQL stored procedure
Does anyone know how to convert this cfquery to TSQL so it can be executed
through a stored procedure instead in MS SQL 2000? The first condition just
sees if a var exists and makes sure its not null, the second one does the same
thing but feeds the query a list:
<cfquery name="test" datasource="abcinc">
select *
from profiles
where 0=0
<cfif isdefined('form.firstname') and form.firstname neq ''>and
firstname='#form.firstname#'</cfif>
<cfif isdefined('zipsreturned') and zipsreturned neq "">
and zipcode in (<cfqueryparam cfsqltype="cf_sql_varchar" value="#zipsreturned#"
list="yes">)</cfif>
</cfquery>
I'm having a tuff time creating the condition in the WHERE part to check if the
variable form.firstname exists first, and then to make sure its not null.
I'm trying to build a search form and then have the search criteria queried in
a MS SQL Server stored procedure directly for the sake of speed.
I appreciate any help. Thanks.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Logware (www.logware.us): a new and convenient web-based time tracking
application. Start tracking and documenting hours spent on a project or with a
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:195800
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54