Wrox Home  
Search P2P Archive for: Go

  Return to Index  

sql_language thread: Use results of stored procedures as the IN-list of an other- query


Message #1 by Imar Spaanjaars <Imar@S...> on Fri, 19 Jan 2001 13:47:44 +0100
I indeed tried this:

         Select blah, blah, blah FROM blah where blah in (exec somestoredproc)

but unfortunately this doesn't work.

I looked into User Functions in SQL 2000 and they seem very promising to 
me. But, I am "forced" to work with SQL 7, so I have to figure out other 
ways to do it.
Temp tables might do the trick, or maybe I need to rethink my strategy all 
together.

Basically what I am trying to accomplish is the sort of navigation that 
Yahoo uses. The "You are here: Home > Cat 1 > Sub Cat 1 > Sub sub Cat 1", 
including the subcategories, the articles in each category and a count for 
both of em. Maybe I should break it up in a few parts, but still the 
recursion on sub categories is bothering me......

Thanks for your input.

Imar



At 08:14 AM 1/19/2001 -0600, you wrote:
>If you are using SQL2000 then you can accomplish what you wish by using a
>user-defined function.  I am doing the very thing you want to do in my
>stored procedures.  It's not quite so straight forward, but it works.  The
>syntax would look something like:
>
>Select blah, blah, blah FROM  blah  where blah in (select id from
>@tempfunction(with_parameters_if_used))
>
>The user defined function needs to be either an In-Line function or a
>function that returns a TABLE-VARIABLE.
>See BOL for details.  I have not worked with the in-line functions, just
>ones that return tables.
>By the way, MS recommends now in SQL2000 to use Table Variables rather than
>temporary tables - they say it's much faster.  The results I have been
>getting are that user defined functions are also faster than stored
>procedures.  They have their limits, and you'll discover them quickly if you
>have any imagination, but they will come in handy.
>
>If you're not using SQL2000, then the only other suggestion I have is to try
>(I haven't done it) the following:
>
>Select blah, blah, blah FROM blah where blah in (exec somestoredproc)
>
>Hope this helps.


  Return to Index