title: How to avoid large in clause?
body: <p>I have 3 tables :</p>
  
  <pre><code>table_product (30 000 row)
  ---------
  ID
  label
  </code></pre>
  
  <p>_</p>
  
  <pre><code>table_period (225 000 row)
  ---------
  ID 
  date_start
  date_end
  default_price
  FK_ID_product
  </code></pre>
  
  <p>and </p>
  
  <pre><code>table_special_offer (10 000 row)
  -----
  ID
  label
  date_start,
  date_end,
  special_offer_price
  FK_ID_period
  </code></pre>
  
  <p>So I need to load data from all these table, so here it's what I do :
  1/ load data from "table_product" like this</p>
  
  <pre><code>select *
  from table_product
  where label like 'gun%'
  </code></pre>
  
  <p>2/ load data from "table_period" like this</p>
  
  <pre><code>select *
  from table_period
  where FK_ID_product IN(list of all the ids selected in the 1)
  </code></pre>
  
  <p>3/ load data from "table_special_offer" like this</p>
  
  <pre><code>select *
  from table_special_offer
  where FK_ID_period IN(list of all the ids selected in the 2)
  </code></pre>
  
  <p>As you may think the IN clause in the point 3 can be very very big (like 75 000 big), so I got a lot of chance of getting either a timeout or something like " An expression services limit has been reached".</p>
  
  <p>Have you ever had something like this, and how did you manage to avoid it ? </p>
  
  <p>PS :
  the context : SQL server 2005, .net 2.0
  (please don't tell me my design is bad, or I shouldn't do "select *", I just simplified my problem so it is a little bit simpler than 500 pages describing my business).</p>
  
  <p>Thanks.</p>