views:

49

answers:

4

Is there a dependable way to find dependencies among views and tables in SQL Server 2005? sys.sql_dependencies doesn't list all of my dependencies. (I thought I saw a similar thread here but can't find it now. Sorry if this is a dup).

A: 

Is this the thread you were looking for?

wallyk
+1  A: 

No - SS 2005's dependency information is incomplete, that's why they introduced sql_expression_dependencies in 2008. If you're stuck on 2005, there's nothing you can really do, short of parsing all the objects yourself. There are extra tools that do this for you, have a look at the other dependency threads for links.

thecoop
A: 

You have one main option only for code

select
    object_name(object_id), m.*
from
    sys.sql_modules m
where
    m.definition like N'%searchstring%'

syscomments and INFORMATION_SCHEMA.routines have nvarchar(4000) columns so may not be reliable

For all objects:

SELECT object_name(object_id), * FROM sys.sql_modules WHERE definition LIKE '%searchstring%'
UNION
SELECT object_name(object_id), * FROM sys.computed_columns WHERE definition LIKE '%searchstring%'
UNION
SELECT object_name(object_id), * FROM sys.check_constraints WHERE definition LIKE '%searchstring%'
UNION
SELECT object_name(object_id), * FROM sys.default_constraints WHERE definition LIKE '%searchstring%'
gbn