| Posted by Kristian Damm Jensen on 10/16/06 11:26 
Henrik Juul wrote:> How do I call my Stored Procedure recursively:
 >
 > CREATE PROCEDURE dbo.GetParentIONode
 > (
 > @IONodeID int,
 > @FullNodeAddress char(100) OUTPUT
 > )
 >
 > AS
 > BEGIN
 > DECLARE @ParentIONodeID int
 > IF EXISTS (SELECT ParentIONodeID FROM IONodes WHERE IONodeID =
 > @IONodeID) BEGIN
 >  SET @FullNodeAddress = CAST((SELECT ParentIONodeID FROM IONodes WHERE
 > IONodeID = @IONodeID) AS VARCHAR) + ' / ' + @FullNodeAddress
 >  --CALL SP Again with @ParentIONodeID and @FullNodeAddress until
 > ParentIONodeID = NULL
 >  SELECT @FullNodeAddress
 > END
 > END
 > GO
 
 Like you would call any other stored procedure. But you can't use the result
 set from a stored procedure directly in your where clause. You have to store
 it in a temptable.
 
 --
 Regards,
 Kristian Damm Jensen
 "This isn't Jeopardy. Answer below the question."
  Navigation: [Reply to this message] |