Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>My first instinct would be to pump your 5000 inputs into a single-column temporary table X, possibly index it, and then use:</p> <pre><code>SELECT X.thecol FROM X JOIN ExistingTable USING (thecol) </code></pre> <p>to get the ones that are present, and (if both sets are needed)</p> <pre><code>SELECT X.thecol FROM X LEFT JOIN ExistingTable USING (thecol) WHERE ExistingTable.thecol IS NULL </code></pre> <p>to get the ones that are absent. Worth benchmarking, at least.</p> <p>Edit: as requested, here are some good docs &amp; tutorials on temp tables in SQL Server. <a href="http://www.sqlteam.com/article/temporary-tables" rel="nofollow noreferrer">Bill Graziano</a> has a simple intro covering temp tables, table variables, and global temp tables. <a href="http://www.sql-server-performance.com/articles/per/temp_tables_necessary_p1.aspx" rel="nofollow noreferrer">Randy Dyess</a> and <a href="http://sqlserver-qa.net/blogs/perftune/archive/2008/01/17/3228.aspx" rel="nofollow noreferrer">SQL Master</a> discuss performance issue for and against them (but remember that if you're getting performance problems you do want to benchmark alternatives, <em>not</em> just go on theoretical considerations!-).</p> <p>MSDN has articles on <a href="http://msdn.microsoft.com/en-us/library/ms190768.aspx" rel="nofollow noreferrer">tempdb</a> (where temp tables are kept) and <a href="http://msdn.microsoft.com/en-us/library/ms175527.aspx" rel="nofollow noreferrer">optimizing</a> its performance.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload