-2

Do you know if there is a limit of the the numbers of elements we can write in a IN expression ? (with SQL Server)

ex :

SELECT *
FROM table
Where toto IN (1,2,3...., Max ?) 

thank you ;)

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
ROCHEDY
  • 85
  • 11
  • Why would you want to do that? If you have a long list of values, you probably need to rethink your query. eg join with the source table of the values. If the data comes from an external source you can use a table-valued parameter to pass the data. – Panagiotis Kanavos Apr 07 '14 at 15:44
  • possible duplicate of [Limit on the WHERE col IN (...) condition](http://stackoverflow.com/questions/1069415/limit-on-the-where-col-in-condition) – 0x9BD0 Apr 07 '14 at 15:45
  • http://stackoverflow.com/questions/1869753/maximum-size-for-a-sql-server-query-in-clause-is-there-a-better-approach – the_lotus Apr 07 '14 at 15:45
  • Theses answers don't help me ! how many items can i write in the IN condition ?! – ROCHEDY Apr 08 '14 at 08:11

1 Answers1

0

The Oracle SQL DB allows for a maximum of 1000 elements for in statements. However, you are not limited to 1000 elements if you use a select statement rather than specifying each element.

SELECT *
FROM table
Where toto IN (SELECT toto FROM other) 

I've used this when I have queries run for long periods of time that my otherwise timeout. This thread may also be helpful for you https://community.oracle.com/thread/235143

Gibado
  • 168
  • 1
  • 7