List objects dependency on a database

Configurare noua (How To)

Situatie

Mai jos este un view care listeaza dependentele dintre obiectele bazei de date pe care este rulat.

Solutie

— select * from [ObjectDependencyMap]

 

CREATE view [ObjectDependencyMap]

as

select
referencing.*,
referenced.child_dbobject_id,
referenced.child_dbbobject_schema,
referenced.child_dbobject,
referenced.child_dbobject_type
from
(
select
[object_id] [dbobject_id],
schema_name([schema_id]) [dbobject_schema],
name [dbobject],
type_desc [dbobject_type]
from sys.objects
where [type] not in (‘D’,’IT’,’PK’,’SQ’,’UQ’,’U’,’S’,’TR’)
) referencing
left outer join
(
select
id [parent_dbobject_id],
depid [child_dbobject_id],
schema_name([schema_id]) [child_dbbobject_schema],
name [child_dbobject],
type_desc [child_dbobject_type]
from sysdepends
join sys.objects
on [object_id] = depid
group by id,depid,[schema_id],name,type_desc
) referenced
on referencing.dbobject_id = referenced.parent_dbobject_id

Tip solutie

Permanent
Etichetare:

Voteaza

(13 din 17 persoane apreciaza acest articol)

Despre Autor

Leave A Comment?