How to know where all my procedure called?

  • Hi,

    I have a procedure which is used in multiple areas like Jobs, Stored procedures etc.,  If I have to know where all my procedure is called, how do I know that?

    Thanks in advance,

     Mahesh

  • You might try sp_grep.  Look at http://www.sqlservercentral.com/scripts/viewscript.asp?scriptid=1201

  • --to find objects (procedures, etc) which reference your procedure:

    select sysobjects.name

    from sysobjects

    inner join syscomments on sysobjects.id = syscomments.id

    where syscomments.text like '%mysp_name%'

    --to find sql agent jobs which reference your procedure:

    select sysjobs.name, sysjobsteps.step_name

    from msdb.dbo.sysjobs sysjobs

    inner join msdb.dbo.sysjobsteps sysjobsteps on sysjobs.job_id = sysjobsteps.job_id

    where sysjobsteps.command like '%mysp_name%'

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

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