0

This is the first time I've encountered an error message that made me feel like I deserved an award:

Msg 8623, Level 16, State 1, Line 1 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 partitions. Please simplify the query. If you believe you have received this message in error, contact Customer Support Services for more information.

All I was trying to do was lookup usernames associated with a given set of student first and last names. Suppose there's a table with Username, FName, and LName fields. If I give you 300 first and last name pairs, use them to look up their usernames. What's the best way to query the data?

SQL Server obviously can't handle a query of the form:

select Username, 1 from Table where FName='john' and LName='doe'
union all select Username, 2 from Table where FName='jane' and LName='doe'
union all ... --and so on
... --for each fname/lname pair

The field doesn't have to be username, it could be any associated field such as address, phone number, etc.

Triynko
  • 18,766
  • 21
  • 107
  • 173

1 Answers1

0

I suppose I could dump the names into a table first, then just do a left join on it.

Triynko
  • 18,766
  • 21
  • 107
  • 173