SQL Server : execute stored procedure from another stored procedure I have two stored procedures.


Proc1 executes a SQL statement and results a data table as a result set.
I need to use the datatable in a select SQL that resides in proc2 as a datasource. like, 

SELECT Col1 
FROM (Exec Proc1)



How can I do it? This syntax here shows error in SQL Server.
you could store your result in a Table Variable

DECLARE @TableVar TABLE (col1 varchar,col2 int,...)
insert into @TableVar
exec (Proc1)

select Col1 from @TableVar