Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

procedure that handle other procedures from within 1

Status
Not open for further replies.

lechuck

Programmer
Sep 4, 2000
26
SE
I have two procedures, that returns data from the same table, but with diffrent where clauses.

In some cases the procedures returns a row that exist in the result from both procedures. (I have an ID field in the table)

Now I need help with a third procedure that executes sp1 and sp2, and if no duplicate row exist it returns the result of sp2.
But if any duplicate rows (same rowID) exsist in both results, the new procedure should return the result of sp2 excluding the rows that exists in the result from both sp1 and sp2.

Tricky to explain my problem in this late hour, my brain get deadlocks all the time now...hope you can understand my problem and help me with it.
 
Something like this should do the trick. Good luck!

Code:
CREATE PROC sp3
AS BEGIN
  --Holding place for sp1 data
  CREATE TABLE #temp1 ...

  --Holding place for sp2 data
  CREATE TABLE #temp2 ...

  INSERT INTO #temp1 (column list)
  EXEC sp1

  INSERT INTO #temp2 (column list)
  EXEC sp2

  SELECT * from #temp2
  WHERE RowID NOT IN (SELECT RowID FROM #temp1)
END

--Angel [rainbow]
-----------------------------------
Behold! As a wild ass in the desert
go forth I to do my work.
--Gurnie Hallock (Dune)
 
could you post your code?

"Shoot Me! Shoot Me NOW!!!"
- Daffy Duck
 
Thanks AngelTampaBay!
Your tip realy did the trick.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top