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!

SP in IN 1

Status
Not open for further replies.

balor

Programmer
Jul 24, 2000
74
Hi,

I want to use the values from a sp in a WHERE-Clause. Do any one have a example of how I can do that in the simplest way.

This is what I want to do:

SELECT
*
FROM
Table1
WHERE
Table1.ID IN (SELECT ID FROM sp_GetID)

 
You cannot use stored procedure in this way. If u had function then u could. SQL server 2000 introduces functions.
But I think, if I know what u actually want to do I can give u a suggestion. I mean actually what should be the return value of SP.
 
Yes I know I can't use sp in this way. It was only a example of what I want to do. I can solve it in many different ways but I want to do it as simple as possible because I'm going to add this criteria to many different procedures.


 
But you don't answer my question what would be the return value of your sp. let me know.
 
You could use a temporary table.

Create Table #temp (ID int)
Insert #temp
Execute sp_GetID

SELECT
*
FROM
Table1
WHERE
Table1.ID IN (SELECT ID FROM #temp)

Drop table #temp Terry
_____________________________________
Man's mind stretched to a new idea never goes back to its original dimensions. - Oliver Wendell Holmes
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top