EXEC sys.sp_refreshsqlmodule 'dbo.MyProcFnOrView'
That will update your dependencies table, allowing you to use sp_depends even if the objects weren't inserted in order. New to 2005, thankfully someone at MS realized and fixed sp_depends' weakness.
When objects are added, rows are added to the internal dependency table. However, it's very easy to get out of sync - say if you add SP A that calls SP B, but add them in the reverse order. Which _never_ happens. Sure.
So, anyhow. Use that, then use one of the handy pieces of code online that assume that the dependency table always works.
UPDATE 2012:
or, you could always use the versions that 2008+ have (don't bother on 2005; not there):
sys.dm_sql_referenced_entities
sys.dm_sql_referencing_entities
sys.sql_expression_dependencies
No comments:
Post a Comment