Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2002-03-27 : 11:16:48
|
Dennis writes "First, Thanks in advanceLet's say I have a stored procedure that comprises of two select staments,for example:create proc MyProc as select * from A select * from Bend procwhen I execute this stored procedure I get two record sets (of course)I want to call this stored procedure from another stored procedure then gothrough the recordsets individually:That is, if I call MyProc like thiscreate proc TopProc as exec MyProc ---- I want to manipulate the two recordsets returned from the above "exec" statement SEPARATELY using SQL ----end procThanks!" |
|
setbasedisthetruepath
Used SQL Salesman
992 Posts |
Posted - 2002-03-27 : 11:22:05
|
You're mixing semantics. Stored procedures don't return recordsets; they are an ADO abstraction. Stored procedures return rowsets. Are the rowset definitions the same ( column types and #'s match )? If so you can UNION them and then access the rowset as follows:create proc aselect * from table_aunionselect * from table_bcreate proc bcreate table #temp ( ... )insert #temp exec asetBasedIsTheTruepath<O> |
|
|
MichaelP
Jedi Yak
2489 Posts |
Posted - 2002-03-27 : 11:26:22
|
What about putting the "recordsets" into a temp table, manipulate them with t-sql, and then do a select on the temp table to return the data you need?SELECT * INTO #TempA FROM (SELECT * FROM a)SELECT * INTO #TempB FROM (SELECT * FROM b)--Insert code here to manipulate #TempA and #TempBSELECT * from #TempASELECT * from #TempBDROP TABLE #TempADROP TABLE #TempAIf the data is exactly the same, it's possible you could put all the data into one temp table. If there are 100'sk-1000k records or so, temp tables might not be such a good idea. Just try it out and see how performance is with your particular datasets.Michael |
|
|
MichaelP
Jedi Yak
2489 Posts |
Posted - 2002-03-27 : 11:28:26
|
Sniped! But we had basically the same idea :)<Yoda>Set based, true path it is....yesssss</Yoda>Michael |
|
|
setbasedisthetruepath
Used SQL Salesman
992 Posts |
Posted - 2002-03-27 : 11:35:54
|
So nice to be loved quote: <Yoda>Set based, true path it is....yesssss</Yoda>
setBasedIsTheTruepath<O> |
|
|
|
|
|