T-SQL stored procedures can be too large to manage. If the query optimizer gives up trying to come up with a good query plan (and it will if it feels the query is too complex), you need to simplify your stored procedure. Executing four 100-line stored procedures is often better than executing one 400-line procedure.