I have a SQL Query build as a string but i cant seem to pass it into to the <cfquery>

But it does not work

any one can help me?

<cfif ISDEFINED ('member')>
<CFSET SQL = "SELECT *
FROM precontract ">  
<CFSET SQL_Coubr = 0 >
<cfif form.member neq  "">
	<cfif SQL_Coubr eq  0>
    	<CFSET SQL = SQL& " WHERE " >
    <cfelse>
    	<CFSET SQL = SQL& " OR " >  
    </cfif>      
	<CFSET SQL = SQL& " name LIKE '%#form.member#%' " >
    <CFSET SQL_Coubr = 1 >
</cfif>      

<cfif form.Email neq  "">
	<cfif SQL_Coubr eq  0>
    	<CFSET SQL = SQL& " WHERE " >
    <cfelse>
    	<CFSET SQL = SQL& " OR " >  
    </cfif>      
	<CFSET SQL = SQL& " email LIKE '%#form.Email#%' " >
    <CFSET SQL_Coubr = 1 >
</cfif>      

<cfif form.Phone neq  "">
	<cfif SQL_Coubr eq  0>
    	<CFSET SQL = SQL& " WHERE " >
    <cfelse>
    	<CFSET SQL = SQL& " OR " >  
    </cfif>      
	<CFSET SQL = SQL& " phone  LIKE '%#form.Phone#%' " >
    <CFSET SQL_Coubr = 1 >
</cfif>  

<cfif form.ContractNumber neq  "">
	<cfif SQL_Coubr eq  0>
    	<CFSET SQL = SQL& " WHERE " >
    <cfelse>
    	<CFSET SQL = SQL& " OR " >  
    </cfif>      
	<CFSET SQL = SQL& " conID LIKE '%#form.ContractNumber#%' " >
    <CFSET SQL_Coubr = 1 >
</cfif>  
<cfoutput>#SQL#</cfoutput>
<cfquery datasource="mssqlcf_modelprod" dbname="modelprod"  name="get_prememb">
        SQL    
</cfquery>
</cfif>

You have <cfoutput>#SQL#</cfoutput>
but in the cfquery you only have SQL, try enclosing the #SQL#

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.