using 'for each' record in a table


using 'for each' record in a table


I've been failing in executing a complicated select which joins two large tables. When tried to execute it for a specific record of the first table, it runs perfectly and fast. I tried to collect statistics and use all other, known to me, optimizing methods, with no success.

Is there a way, as part of a regular query (if not, then as part of a stored procedure) to use a 'for each' logic?
If I could run through each row on the first table, and for each execute the query, my problem would be solved.



Tags (1)
Junior Contributor

Re: using 'for each' record in a table

The only 'for each' in SQL is a cursor, which is usually considered as evil.

To get help you have to post more info:
What means 'failing'?
What's your actual query plus DDL and explain