How to call a stored procedure in where where SQL

I have a T-SQL script, the requirement is that I need to call the stored procedure in where where. This stored procedure takes a parameter and returns a bit of result. Please help me how to do this.

thank

Edit: I cannot change this sp and make it a function. you are welcome

+5
source share
2 answers

You cannot use Stored Procedurewhere in the clause, but you can use where in the clause User Defined Function.

If you cannot convert SP to a function, you first need to get the bit value from the SP execution and use this variable in the where section ..

+5
source

where. , , . ,

create table #spResult ({columns as result of your sp})

insert into #spResult exec YourSP ({input parameters})

select * from yourtable 
where col in (select col from #spResult) 

drop table #spResult 
+4

All Articles