tsql - Select IN on more than 2100 values -


how can select in on more 2100 values?

<cfquery name="result.qrydata">   select    sub_acct_no,  ...    dbo.closed_order   ord_no in <cfqueryparam cfsqltype="cf_sql_varchar" value="#valuelist(qryord.ord_no)#" list="yes"> </cfquery> 

because of ways tables setup, linked servers , joins not option.

when ran error thrown because there new many fields being passed in.

first load values xml

<cfset var strresult = '<ul class="xoxo">'> <cfloop query="qryord">     <cfset strresult &= '<li>#xmlformat(ord_no)#</li>'> </cfloop> <cfset strresult &= '</ul>'> 

then use xml in sql query

<cfquery name="result.qrydata"> declare @xmlord_no       xml = <cfqueryparam cfsqltype="cf_sql_varchar" value="#strresult#">   declare @tblord_no          table (id varchar(20))   insert @tblord_no select tbl.col.value('.', 'varchar(20)')    @xmlord_no.nodes('/ul/li') tbl(col)   select  sub_acct_no,  ...    dbo.closed_order   ord_no in (select id @tblord_no) </cfquery> 

you can dump of xml , formatted in html

 <cfoutput>#strresult#</cfoutput> 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -