Using a stored procedure like a subquery

Question:
I’m trying to get something like this to work. How can I take the output of a stored procedure and use it in a subquery?

create procedure pcore asselect e_id from emails where e_id like ("%1%")create procedure pevalasselect e_id from emailswhere e_id in(execute pcore)

Answer:
The way to accomplish your task is to create a temp table with the same structure as the result set from your stored procedure. Then execute an insert into #temptable:

(    exec pcore)

You can then use your temp table in your subquery.

Share the Post:
Share on facebook
Share on twitter
Share on linkedin

Overview

Recent Articles: