Created
January 30, 2014 20:31
-
-
Save ronmichael/8718101 to your computer and use it in GitHub Desktop.
MSSQL: Report on all database objects that have nothing else depending on them - that are not referenced by any other objects in the database.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select o.type_desc type, o.name | |
from sys.OBJECTS o | |
left join sys.sql_expression_dependencies ref on ref.referenced_id = o.object_id | |
left join sys.OBJECTS o2 on o2.object_id = ref.referencing_id | |
where o2.name is null | |
and o.type_desc not in ('SYSTEM_TABLE','SQL_TRIGGER','INTERNAL_TABLE','SERVICE_QUEUE','TYPE_TABLE') | |
and o.type_desc not like '%CONSTRAINT%' | |
order by o.type_desc, o.name |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment