I was asked yesterday by a co-worker how we can pull dependency information from the database for a given table / column. Having not really looked into this in great detail it took me a few minutes but I found the sys.sys_dependencies catalog view. (The many views that are provided in 2005 have been such an eye-opener into the DBMS!) I was able to come up with something pretty simple but my co-worker came across a post from Umachandar Jayachandran (http://blogs.msdn.com/sqltips/archive/2005/07/05/435882.aspx) that covered most of our needs. However, we still needed to gather replication related dependencies so, I modified it to inlude that as well. I realize that 2005 does a much better job of handling ddl changes to replicated objects but, it sure is nice to have a little view beforehand to see what you are going to be potentially affecting before making any changes. So, the script from Umachandar Jayachandran with my changes for replication information is below. Hope it is helpful to someone else out there as well.
declare@table varchar(100) , @column varchar(100) select @table = 'YourTable'select @column = 'YourColumn'; with rel_objs (obj_name, type_name, type_desc, parent_object_id, parent_column_id)as(select d.name, d.type, d.type_desc, d.parent_object_id, d.parent_column_idfrom sys.default_constraints as d -- defaultsunion allselect c.name, c.type, c.type_desc, c.parent_object_id, c.parent_column_idfrom sys.check_constraints as c -- check constraintsunion allselect k.name, k.type, k.type_desc, k.parent_object_id, kc.column_idfrom sys.key_constraints as k -- primary key and unique constraintsjoin sys.index_columns as kcon kc.object_id = k.parent_object_id and kc.index_id = k.unique_index_idunion allselect f.name, f.type, f.type_desc, f.parent_object_id, fc.parent_column_idfrom sys.foreign_keys as f -- foreign key constraintsjoin sys.foreign_key_columns as fcon fc.constraint_object_id = f.object_id and fc.parent_object_id = f.parent_object_idunion allselect c.name, 'CC', 'COMPUTED_COLUMN', d.referenced_major_id, d.referenced_minor_idfrom sys.sql_dependencies as d -- computed columnsjoin sys.columns as con c.object_id = d.object_id and c.column_id = d.column_idwhere d.object_id = d.referenced_major_id and d.referenced_minor_id > 0 and d.column_id > 0union allselect o.name, o.type, o.type_desc, d.referenced_major_id, d.referenced_minor_idfrom sys.sql_dependencies as d -- viewsjoin sys.objects as oon o.object_id = d.object_idwhere d.object_id <> d.referenced_major_id and d.referenced_minor_id > 0 and o.type = 'V'union allselect i.name, 'IX', i.type_desc, i.object_id, ic.column_idfrom sys.indexes as i -- indexesjoin sys.index_columns as icon ic.index_id = i.index_id and ic.object_id = i.object_idwhere i.is_primary_key = 0 and i.is_unique_constraint = 0), rel_objs_det (schema_name, table_name, column_name, rel_obj_name, rel_type_name, rel_type_desc, column_replication_status, object_replication_agent)as (select s.name, o.name, c.name, r.obj_name, r.type_name, r.type_desc, casewhen c.is_replicated = 1 OR c.is_merge_published = 1 OR c.is_dts_replicated =1 THEN 'Column Replicated'else 'Not Replicated'end as column_replication_status, sp.name as object_replication_agentfrom rel_objs as r -- names for the table/column to query for:join sys.objects as oon r.parent_object_id = o.object_idjoin sys.columns as con c.object_id = o.object_id and c.column_id = r.parent_column_idjoin sys.schemas as son s.schema_id = o.schema_idleft join sysarticles saon o.object_id = sa.objidleft join syspublications spon sa.pubid = sp.pubid)select r.schema_name, r.table_name, r.column_name, casewhen r.rel_obj_name like 'syncobj_%' then 'Replication View'else r.rel_obj_nameend as rel_obj_name, r.rel_type_name, r.rel_type_desc, r.column_replication_status, r.object_replication_agentfrom rel_objs_det as r/* MODIFY or REMOVE where clause if you want run this query for other tables. */where r.table_name = @Table-- and r.column_name like @Column;