Max size of a Select statement

  • Can any of you tell me how long a SELECT ~ WHERE key IN (?,?,?,?,....) can be. Is it any other limit to be considered then the one from Online Help? - Length of a string containing SQL statements (batch size) 65,536 * Network packet size. The select is dynamic in size and dump when the length of the select statement is appr. 8 KB.

    The SQL version is 2000 SP3.

    Regards Anna-Lena

  • I do not know specifically if the "IN (...)" has a size / items limit, but I've submitted lengthy SQL statements to SQL Server without problems. One exception I have seen is the # of UNIONS in a derived table (~400+). Same exception, but much smaller # of UNIONS in SQL ServerCE (<100).



    Once you understand the BITs, all the pieces come together

  • Your query would be faster, smaller, and more easily maintained if you put the values in a table and join to that table rather than using a list with IN().

    --Jonathan



    --Jonathan

  • quote:


    Your query would be faster, smaller, and more easily maintained if you put the values in a table and join to that table rather than using a list with IN().

    --Jonathan


    cannot comply "loud" enough to you jonathan - last month one of our developers showed up and asked "why is that query soooo slow, is it because the stmt is 64K?" ...

    ... imagine my frustration seeing such crap!

    best regards,

    chris.

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply