For example, when I run it with 10,000 joins:
- Msg 8631, Level 17, State 1, Line 1
- Internal error: Server stack limit has been reached. Please look for potentially deep nesting in your query, and try to simplify it.
When I drop it down to a much more realistic 5,000 joins:
- Msg 4074, Level 16, State 1, Line 1
- Client drivers do not accept result sets that have more than 65,535 columns.
Ah! Okay, that’s fair. (That’s also two error messages I’ve never seen before. Probably a good thing.) Alright, let’s take out the SELECT * and replace it with SELECT p1.* and see what happens:
This is a fun read.