question

NaveenaJaineera-9056 avatar image
0 Votes"
NaveenaJaineera-9056 asked ErlandSommarskog answered

Capturing mutiple recordsets from a stored procedure into multiple temp table

Hi Experts,

I have a stored procedure which returns 2 record sets, would like to capture both in separate temp tables. Is there any way to do?

Please help.

Thanks,
Naveen J V

sql-server-transact-sql
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

OlafHelper-2800 avatar image
0 Votes"
OlafHelper-2800 answered

That's not possible, you can insert only the first resultset to one target table.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

ErlandSommarskog avatar image
0 Votes"
ErlandSommarskog answered

I'd like to modify Olaf's answer a little bit.

It is possible if the two temp tables have the same set of columns. In that case, you can use INSERT-EXEC.

On my web site I have an article How to Share Data Between Stored Stored Procedures, where I discuss alternatives.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.