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 |
emmett
Starting Member
4 Posts |
Posted - 2006-11-10 : 04:50:57
|
Hi,I have two sp's which return the resultsets like these:SP1objectID objectValue1 objectValue2--------- -------------- ---------------1 13 272 21 313 <NULL> 1024 5 3 5 27 <NULL>SP2objectID objectValue3 objectValue4--------- -------------- ---------------1 11.11.1980 15.03.19882 17.12.1985 <NULL>3 18.05.1997 14.11.19944 <NULL> 21.07.1981 5 01.01.2005 <NULL> And i want to join these resultsets in a temp table like this:#tempTableObjectsobjectID objectValue1 objectValue2 objectValue3 objectValue4--------- -------------- -------------- -------------- ---------------1 13 27 11.11.1980 15.03.19882 21 31 17.12.1985 <NULL>3 <NULL> 102 18.05.1997 14.11.19944 5 3 <NULL> 21.07.19815 27 <NULL> 01.01.2005 <NULL> I have to use these resultsets in a join query but how?Or, is there any other solution for this without using cursors?Thanks. |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-11-10 : 04:57:55
|
[code]create table #r1( objectID int, objectValue1 int, objectValue2 int)create table #r2( objectID int, objectValue3 int, objectValue4 int)insert into #r1 exec sp1insert into #r2 exec sp2select r1.objectID, objectValue1, objectValue2, objectValue3, objectValue4from #r1 r1 inner join #r2 r2on r1.objectID = r2.objectID[/code] KH |
 |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2006-11-10 : 04:58:56
|
Yes. INSERT the first resultset into a temporary table #temp1.INSERT the second resultset into a temporary table #temp2.Now select from the both temporary tables with a JOIN on objectid.Peter LarssonHelsingborg, Sweden |
 |
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2006-11-10 : 04:59:07
|
Firstly you wil have to put both these resultsets into two temp tables:Insert into #temp1Exec sp1Insert into #temp2Exec sp1Select t1.ObjectID, t1.ObjectValue1, t1.ObjectValue2,t2.ObjectValue3, t2.ObjectValue4From #temp1 t1join#temp2 t2on t1.ObjectID = t2.ObjectID Sniped!! Harsh AthalyeIndia."Nothing is Impossible" |
 |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-11-10 : 05:00:08
|
   KH |
 |
|
|
|
|
|
|