Sql query: use where in or foreach?

Posted by phenevo on Stack Overflow See other posts from Stack Overflow or by phenevo
Published on 2010-04-27T19:18:01Z Indexed on 2010/04/27 19:23 UTC
Read the original article Hit count: 257

Filed under:
|
|

Hi,

I'm using query, where the piece is:

...where code in ('va1','var2'...')

I have about 50k of this codes.

It was working when I has 30k codes, but know I get:

The query processor ran out of internal resources and could not produce a query plan. This is a rare event and only expected for extremely complex queries or queries that reference a very large number of tables or partition

I think that problem is related with IN...

So now I'm planning use foreach(string code in codes) ...where code =code

Is it good Idea ??

© Stack Overflow or respective owner

Related posts about c#

Related posts about sql-server-2005