title: Selecting id from database where not in large collection, Too many parameters provided
body: <p>I am working on a application that has two databases.</p>
  
  <p>I have an object, let's call it <code>permit</code>, that has a list of id's referencing to id's from a table, lets call that <code>tasks</code>, in the other database. </p>
  
  <p>I am trying to run the following query:</p>
  
  <pre><code>var listOfUsedIds = select taskid from Permit_Task;
  Select * from task where id not in (listOfUsedIds)
  </code></pre>
  
  <p>When I run this code I get the error:</p>
  
  <blockquote>
    <p>The incoming tabular data stream (TDS) remote procedure call (RPC)
    protocol stream is incorrect.<br>
    Too many parameters were provided in this RPC request. The maximum
    is 2100.</p>
  </blockquote>
  
  <p>I can't run a sub select or any thing because NHibernate won't let me do that over two databases.</p>
  
  <p>Can anyone help me how to work around this problem?</p>