I have a stored procedure that returns multiple recordsets for use in an application. Sometimes some of those recordsets are empty.
I'd like to reduce overhead and only return those which have 1 or more rows.
My question is - How can I only return those recordsets which have rows?
The application simply expects 0 or more recordsets, and loops through each, and prints them out.
I know I can skip them in the application code, but I am trying to prevent them from being returned at all, if empty.
The procedure is as simple as this:
CREATE PROCEDURE bfsp_PROC_NM AS BEGIN SELECT * FROM TABLE_1 SELECT * FROM TABLE_2 SELECT * FROM TABLE_3 RETURN END GO
In the actual procedure, some of the queries are expensive, so I don't want to have to test the query, then if it returns a row or more, execute it again... as it would be too expensive.