>>Actually that's what I had (I made a mistake in my original post).
>>
>>It turns out that the query was not the problem, it was actually bringing out all the requested records but I was then exporting the result to Excel using SweetPotato Software's Excel stuff and that was choking on a bad date that had been entered by the user (21/02/0011) so I need to put some date validation in my system.
>>
>>Using the
IN (<< m.lcListOfPKs >>)
is actually faster than using the table valued stuff, my only concern is if there is some limit that it might have.
>
>
>I Try limit with this code
>
lnlastValue=33000
>lcListOfPKs = []
>FOR ijk = 1 TO m.lnlastValue
> lcListOfPKs = m.lcListOfPKs + TRANSFORM(m.ijk)+IIF(m.ijk= m.lnlastValue, [], [,])
>NEXT
>
>TEXT TO m.lcSQL NOSHOW TEXTMERGE
> SELECT Homo.*
> FROM Homo
> WHERE Id IN (<< m.lcListOfPKs >>)
>ENDTEXT
>
>lnErr = SQLEXEC(lnSqlHandler, m.lcSQL,[crsTest])
>IF m.lnErr < 1
> AERROR(laErr)
> WAIT WINDOW (laErr(1,2))
>ENDIF
>
>The results are:
>2008R2
>43 000 Items - OK
>44 000 Items - error
>
>
>2005
>32 000 Items - OK
>33 000 Items - error
>
>The Error is
>Connectivity error: [Microsoft][SQL Server Native Client 10.0][SQL Server]Internal error: An expression services limit has been reached. Please look for potentially complex expressions in your query, and try to simplify them.
Thanks for spending the time on this Vladimir