1

How can I achieve something like this :

SELECT * DISTINCT FROM 
(execute dbo.MyStoredProcedure(@ID1,@ID2))

suppose that's inside another stored procedure.

How can I call a stored procedure from another stored procedure and get the result as a table (my select is intended for that)

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Hossein
  • 24,202
  • 35
  • 119
  • 224
  • 5
    have you considered searching? : http://stackoverflow.com/questions/1492411/sql-server-select-from-stored-procedure – Mitch Wheat Mar 03 '13 at 08:45

2 Answers2

2

Try

DECLARE @TableTemp TABLE (--declare parameters, ouput from SP)

INSERT INTO @TableTemp
EXEC dbo.MyStoredProcedure @ID1,@ID2

SELECT * FROM @TableTemp 
Conrad Lotz
  • 8,200
  • 3
  • 23
  • 27
1

You can do something like this.

INSERT INTO #temp 
EXEC MyStoredProcedure(@ID1,@ID2)

SELECT * FROM #temp
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Praveen Nambiar
  • 4,852
  • 1
  • 22
  • 31