checking dependent objects before execution

  • I have a driver procedure that executes 10 other procedures. I need to write a proc. or function that check all the dependent objects RECURSIVELY. Here is a proc. I use to check just one level deep.

    -Kevin

    SET QUOTED_IDENTIFIER ON

    GO

    SET ANSI_NULLS ON

    GO

    ALTER PROC USP_CHECK_DEPEND_OBJECTS @ERRMSG VARCHAR(60) OUTPUT AS

    --USP_CHECK_DEPEND_OBJECTS 'PROC OR TABLE MISSING OR OWNER HAS CHANGED'

    BEGIN

    SET NOCOUNT ON

    --DECLARE @TNAME VARCHAR(50)

    if exists

    (

    select OBJECT_NAME from DEPEND_OBJECTS e

    WHERE NOT exists

    (

    select *

    from sysobjects

    WHERE E.OBJECT_NAME =USER_NAME(UID)+'.' + NAME

    )

    )

    begin

    SET @ERRMSG = 'PROC OR TABLE MISSING OR OWNER HAS CHANGED' --+ @TNAME

    select @ERRMSG

    return 99

    end

    --select @ERRMSG

    SET NOCOUNT OFF

    END

    GO

    SET QUOTED_IDENTIFIER OFF

    GO

    SET ANSI_NULLS ON

    GO

  • Here is a recursive procedure I wrote to calculate a factorial. You might be able to try something like this:

    http://www.geocities.com/sqlserverexamples/#math1

    -------------------------

    Gregory Larsen, DBA

    If you looking for SQL Server Examples check out my website at http://www.geocities.com/sqlserverexamples

    Gregory A. Larsen, MVP

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply