You are here: Re: Recursive Stored Procedure? « MsSQL Server « IT news, forums, messages
Re: Recursive Stored Procedure?

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация