Please have a look at the following statement:
CREATE TABLE TableA (A INT)
CREATE TABLE TableB (B INT, C INT)
DECLARE @stmt NVARCHAR(MAX) = 'SELECT * FROM TableA; SELECT * FROM TableB'
EXEC sp_executesql @stmt
The statement generates an output of two tables. Is it possible to insert the results into two temp tables instead of outputting the result sets? Or (even better) to ignore the results entirely?
Background:
I am writing some generic code to check stored procedures for "compile-errors": It executes all reading stored procedures and checks if any errors come up (e.g. missing columns or impossible execution-plans). Thus in reality, @stmt would contain the call of a stored procedure (which cannot be splitted into two seperate statements). This is working perfectly fine, but I do not like the fact that the code outputs more than a hundred tables...